pakmanaged.js
function wrap(cmd, fn, options) {
      return function() {
        var retValue = null;
    
        state.currentCmd = cmd;
        state.error = null;
    
        try {
          var args = [].slice.call(arguments, 0);
    
          if (options && options.notUnix) {
            retValue = fn.apply(this, args);
          } else {
            if (args.length === 0 || typeof args[0] !== 'string' || args[0][0] !== '-')
              args.unshift(''); // only add dummy option if '-option' not already present
            retValue = fn.apply(this, args);
          }
        } catch (e) {
          if (!state.error) {
            // If state.error hasn't been set it's an error thrown by Node, not us - probably a bug...
            console.log('shell.js: internal error');
            console.log(e.stack || e);
            process.exit(1);
          }
          if (config.fatal)
            throw e;
        }
    
        state.currentCmd = 'shell.js';
        return retValue;
      };
    }
function wrap(cmd, fn, options) {
      return function() {
        var retValue = null;
    
        state.currentCmd = cmd;
        state.error = null;
    
        try {
          var args = [].slice.call(arguments, 0);
    
          if (options && options.notUnix) {
            retValue = fn.apply(this, args);
          } else {
            if (args.length === 0 || typeof args[0] !== 'string' || args[0][0] !== '-')
              args.unshift(''); // only add dummy option if '-option' not already present
            retValue = fn.apply(this, args);
          }
        } catch (e) {
          if (!state.error) {
            // If state.error hasn't been set it's an error thrown by Node, not us - probably a bug...
            console.log('shell.js: internal error');
            console.log(e.stack || e);
            process.exit(1);
          }
          if (config.fatal)
            throw e;
        }
    
        state.currentCmd = 'shell.js';
        return retValue;
      };
    }
Common wrapper for all Unix-like commands