<commit_before>var fs = require('fs'), net = require('net');

var child_process = require('child_process');

var config = require('../../config').getConfig();

/**
 * Interface to shell worker.
 *
 * Spawns worker.js and sends messages to it.
 */
exports.shell = function (args, router) {

  this.router = router;
  this.buffer = "";

  // Get user
  var user = args.user || process.env.USER;
  var that = this;

  // Extract location of source.
  var p, path = process.argv[1].split('/');
  path[path.length - 1] = 'node_modules/shell/worker.js';
  path = path.join('/');
  
  // Determine user identity.
  if (user == process.env.USER) {
    // Spawn regular worker.
    p = this.process = child_process.fork(path, [], {
      cwd: process.cwd(),
    });
  }
  else {
    // Spawn sudo worker.
    console.log('sudo not implemented');<commit_msg>Pass env to worker<commit_after>var fs = require('fs'), net = require('net');

var child_process = require('child_process');

var config = require('../../config').getConfig();

/**
 * Interface to shell worker.
 *
 * Spawns worker.js and sends messages to it.
 */
exports.shell = function (args, router) {

  this.router = router;
  this.buffer = "";

  // Get user
  var user = args.user || process.env.USER;
  var that = this;

  // Extract location of source.
  var p, path = process.argv[1].split('/');
  path[path.length - 1] = 'node_modules/shell/worker.js';
  path = path.join('/');
  
  // Determine user identity.
  if (user == process.env.USER) {
    // Spawn regular worker.
    p = this.process = child_process.fork(path, [], {
      env: process.env,
      cwd: process.cwd(),
    });
  }
  else {
    // Spawn sudo worker.
    console.log('sudo not implemented');
{'fraction_non_alphanumeric': 0.17333333333333334, 'fraction_numerical': 0.002318840579710145, 'mean_word_length': 2.827050997782705, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4988831', 'n_tokens_mistral': 572, 'n_tokens_neox': 551, 'n_words': 148}