<commit_before>var Node = {
  child: require('child_process'),
  crypto: require('crypto'),
  fs: require('fs'),
  os: require('os'),
  path: require('path'),
  process: process,
  util: require('util')
};

function attempt(attempts, command, options, end) {
  if (typeof attempts !== 'number' || Math.floor(attempts) !== attempts || attempts < 0) {
    return end(new Error('Attempts argument should be a positive integer.'));
  }
  // The -n (non-interactive) option prevents sudo from prompting the user for
  // a password. If a password is required for the command to run, sudo will
  // display an error message and exit.
  var childProcess = Node.child.exec('/usr/bin/sudo -n ' + command,
    function(error, stdout, stderr) {
      if (/sudo: a password is required/i.test(stderr)) {
        if (attempts > 0) return end(new Error('User did not grant permission.'));
        if (Node.process.platform === 'linux') {
          // Linux will probably use TTY tickets for sudo timestamps.
          // If so, we cannot easily extend the sudo timestamp for the user.
          // We prefer this since a single prompt can be used for multiple calls.
          // Instead, we have to use a separate prompt for each call.
          return linux(command, options, end);
        }
        prompt(options,
          function(error) {
            if (error) return end(error);
            attempt(++attempts, command, options, end); // Cannot use ++ suffix here.
          }
        );
      } else if (!error && /^sudo:/i.test(stderr)) {
        end(new Error('Unexpected stderr from sudo command without corresponding error: ' + stderr));
      } else {
        end(error, stdout, stderr);
      }
    }
  );
  if (options.onChildProcess) options.onChildProcess(childProcess);
}

function copy(source, target, end) {
  source = escapeDoubleQuotes(Node.path.normalize(source));
  target = escapeDoubleQuotes(Node.path.normalize(target));
  var command = '/bin/cp -R -p "' + source + '" "' + target + '"';
  Node.child.exec(command, end);
}

function escapeDoubleQuotes(string) {<commit_msg>Remove dependency on locale language when detecting sudo error<commit_after>var Node = {
  child: require('child_process'),
  crypto: require('crypto'),
  fs: require('fs'),
  os: require('os'),
  path: require('path'),
  process: process,
  util: require('util')
};

function attempt(attempts, command, options, end) {
  if (typeof attempts !== 'number' || Math.floor(attempts) !== attempts || attempts < 0) {
    return end(new Error('Attempts argument should be a positive integer.'));
  }
  // The -n (non-interactive) option prevents sudo from prompting the user for
  // a password. If a password is required for the command to run, sudo will
  // display an error message and exit.
  var childProcess = Node.child.exec('/usr/bin/sudo -n ' + command,
    function(error, stdout, stderr) {
      if (/sudo: /i.test(stderr)) {
        if (attempts > 0) return end(new Error('User did not grant permission.'));
        if (Node.process.platform === 'linux') {
          // Linux will probably use TTY tickets for sudo timestamps.
          // If so, we cannot easily extend the sudo timestamp for the user.
          // We prefer this since a single prompt can be used for multiple calls.
          // Instead, we have to use a separate prompt for each call.
          return linux(command, options, end);
        }
        prompt(options,
          function(error) {
            if (error) return end(error);
            attempt(++attempts, command, options, end); // Cannot use ++ suffix here.
          }
        );
      } else {
        end(error, stdout, stderr);
      }
    }
  );
  if (options.onChildProcess) options.onChildProcess(childProcess);
}

function copy(source, target, end) {
  source = escapeDoubleQuotes(Node.path.normalize(source));
  target = escapeDoubleQuotes(Node.path.normalize(target));
  var command = '/bin/cp -R -p "' + source + '" "' + target + '"';
  Node.child.exec(command, end);
}

function escapeDoubleQuotes(string) {
{'fraction_non_alphanumeric': 0.13117588932806323, 'fraction_numerical': 0.0009881422924901185, 'mean_word_length': 2.885796545105566, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '689328', 'n_tokens_mistral': 1177, 'n_tokens_neox': 1137, 'n_words': 393}