home *** CD-ROM | disk | FTP | other *** search
/ Champak 48 / cdrom_image.iso / Games / alex_trax.swf / scripts / __Packages / com / neodelight / flanix / Console.as < prev    next >
Encoding:
Text File  |  2007-10-01  |  26.1 KB  |  824 lines

  1. class com.neodelight.flanix.Console
  2. {
  3.    var width;
  4.    var height;
  5.    var offsetX;
  6.    var offsetY;
  7.    var inputHeight;
  8.    var outputHeight;
  9.    var outputMaxLines;
  10.    var cols;
  11.    var mc;
  12.    var output;
  13.    var input;
  14.    var history;
  15.    var format;
  16.    var cursorMc;
  17.    var codepage;
  18.    var active;
  19.    var parameters;
  20.    var flags;
  21.    static var COLOR_LINE = 65280;
  22.    static var COLOR_BG = 2236962;
  23.    static var COLOR_BG_ALPHA = 100;
  24.    static var COLOR_TEXT = 65280;
  25.    var padding = 5;
  26.    var spacing = 5;
  27.    var promptVar = ">";
  28.    var historyLen = 100;
  29.    var historyPtr = -1;
  30.    var cursorPos = 0;
  31.    var doBufStdOut = false;
  32.    var bufStdOut = "";
  33.    var ram = {CWD:"/",PATH:"/bin:."};
  34.    function Console(width, height)
  35.    {
  36.       if(_global.console)
  37.       {
  38.          trace("#ERROR: Console(): only one instance of Console allowed!");
  39.       }
  40.       else
  41.       {
  42.          com.neodelight.flanix.Kernel.init();
  43.          _global.console = this;
  44.          this.width = !width ? 550 : width;
  45.          this.height = !height ? 400 : height;
  46.          this.offsetX = 0;
  47.          this.offsetY = 0;
  48.          this.inputHeight = 18;
  49.          this.outputHeight = this.height - this.padding * 2 - this.spacing - this.inputHeight;
  50.          this.outputMaxLines = 50;
  51.          this.cols = Math.floor((this.width - this.padding * 2) / 8) - 1;
  52.          this.mc = _root.createEmptyMovieClip(com.neodelight.std.Unique.getKey(),_root.getNextHighestDepth());
  53.          this.mc.createTextField("output",this.mc.getNextHighestDepth(),this.padding,this.padding,this.width - this.padding * 2,this.outputHeight);
  54.          this.output = this.mc.output;
  55.          this.mc.createTextField("input",this.mc.getNextHighestDepth(),this.padding,this.padding + this.outputHeight + this.spacing,this.width - this.padding * 2,20);
  56.          this.input = this.mc.input;
  57.          this.input.text = this.promptVar;
  58.          this.input.addListener(this);
  59.          Key.addListener(this);
  60.          this.history = new Array();
  61.          this.format = new TextFormat();
  62.          this.format.color = com.neodelight.flanix.Console.COLOR_TEXT;
  63.          this.format.font = "Courier";
  64.          this.format.size = 10;
  65.          this.input.setNewTextFormat(this.format);
  66.          this.input.setTextFormat(this.format);
  67.          this.output.setTextFormat(this.format);
  68.          this.output.setNewTextFormat(this.format);
  69.          this.output.wordWrap = true;
  70.          this.cursorMc = this.mc.createEmptyMovieClip(com.neodelight.std.Unique.getKey(),this.mc.getNextHighestDepth());
  71.          this.cursorMc.lineStyle(0,com.neodelight.flanix.Console.COLOR_TEXT);
  72.          this.cursorMc.moveTo(0,0);
  73.          this.cursorMc.lineTo(8,0);
  74.          setInterval(function(cursorMc)
  75.          {
  76.             cursorMc._visible = !cursorMc._visible;
  77.          }
  78.          ,200,this.cursorMc);
  79.          this.cursorMc._y = this.height - this.padding - 2 + this.offsetY;
  80.          this.updateCursor();
  81.          this.codepage = new Array();
  82.          this.codepage[221] = "┬┤";
  83.          this.codepage[304] = "=";
  84.          this.codepage[306] = "\"";
  85.          this.codepage[307] = "┬º";
  86.          this.codepage[310] = "&";
  87.          this.codepage[311] = "/";
  88.          this.codepage[312] = "(";
  89.          this.codepage[313] = ")";
  90.          this.codepage[443] = "*";
  91.          this.codepage[444] = ";";
  92.          this.codepage[446] = ":";
  93.          this.codepage[447] = "\'";
  94.          this.codepage[475] = "?";
  95.          this.codepage[477] = "`";
  96.          this.codepage[482] = ">";
  97.          this.codepage[1584] = "}";
  98.          this.codepage[1591] = "{";
  99.          this.codepage[1592] = "[";
  100.          this.codepage[1593] = "]";
  101.          this.codepage[1617] = "@";
  102.          this.codepage[1723] = "~";
  103.          this.codepage[1755] = "\\";
  104.          this.codepage[1762] = "|";
  105.          this.redraw();
  106.          this.stdout("Neodelight Flash Console " + _global.$FLANIX_VERSION);
  107.          this.stdout("OK.");
  108.          this.active = false;
  109.          this.mc._visible = false;
  110.       }
  111.    }
  112.    function show()
  113.    {
  114.       this.active = true;
  115.       this.mc._visible = true;
  116.       this.mc.swapDepths(_root.getNextHighestDepth());
  117.    }
  118.    function hide()
  119.    {
  120.       this.active = false;
  121.       this.mc._visible = false;
  122.    }
  123.    function echo(msg)
  124.    {
  125.       if(msg == undefined)
  126.       {
  127.          msg = "";
  128.       }
  129.       if(this.output.maxscroll > this.outputMaxLines)
  130.       {
  131.          var _loc2_ = this.output.text.split(String.fromCharCode(13));
  132.          _loc2_.splice(0,_loc2_.length - this.outputMaxLines);
  133.          this.output.text = _loc2_.join("\n");
  134.       }
  135.       else if(this.output.text != "")
  136.       {
  137.       }
  138.       this.output.text += "\n";
  139.       this.output.text += msg;
  140.       this.output.scroll = this.output.maxscroll;
  141.    }
  142.    function stdout(msg)
  143.    {
  144.       if(this.doBufStdOut)
  145.       {
  146.          this.bufStdOut += msg;
  147.       }
  148.       else
  149.       {
  150.          this.echo(msg);
  151.       }
  152.    }
  153.    function flushStdOut()
  154.    {
  155.       this.echo(this.bufStdOut);
  156.       this.bufStdOut = "";
  157.    }
  158.    function stderr(msg)
  159.    {
  160.       this.echo(msg);
  161.    }
  162.    function setExitCode(code)
  163.    {
  164.       this.ram["?"] = code;
  165.    }
  166.    function cls()
  167.    {
  168.       this.output.text = "";
  169.    }
  170.    static function addFunction(id, f)
  171.    {
  172.       _global.bin[id.toLowerCase()] = f;
  173.    }
  174.    function getObjectAtCwd()
  175.    {
  176.       if(this.ram.CWD == undefined)
  177.       {
  178.          this.ram.CWD = "/";
  179.       }
  180.       return this.getObjectAtPath(this.ram.CWD);
  181.    }
  182.    function getObjectAtPath(fullPath)
  183.    {
  184.       if(fullPath.substr(0,1) != "/")
  185.       {
  186.          fullPath = this.ram.CWD + "/" + fullPath;
  187.       }
  188.       var _loc4_ = this.simplifyPath(fullPath).split("/");
  189.       var _loc5_ = _global;
  190.       _global._level0 = _level0;
  191.       _global._level1 = _level1;
  192.       _global._level2 = _level2;
  193.       _global._level3 = _level3;
  194.       var _loc3_ = 0;
  195.       while(_loc3_ < _loc4_.length)
  196.       {
  197.          if(_loc4_[_loc3_] != "")
  198.          {
  199.             _loc5_ = _loc5_[_loc4_[_loc3_]];
  200.          }
  201.          _loc3_ = _loc3_ + 1;
  202.       }
  203.       return _loc5_;
  204.    }
  205.    function getBasePath(fullPath)
  206.    {
  207.       if(fullPath.charAt(fullPath.length - 1) == "/")
  208.       {
  209.          return fullPath;
  210.       }
  211.       if(fullPath.charAt(0) != "/")
  212.       {
  213.          fullPath = this.ram.CWD + "/" + fullPath;
  214.       }
  215.       var _loc3_ = this.simplifyPath(fullPath).split("/");
  216.       _loc3_.pop();
  217.       return _loc3_.join("/") + "/";
  218.    }
  219.    function getFileName(fullPath)
  220.    {
  221.       return String(fullPath.split("/").pop());
  222.    }
  223.    function simplifyPath(fullPath)
  224.    {
  225.       var _loc2_ = fullPath.split("/");
  226.       var _loc1_ = 0;
  227.       while(_loc1_ < _loc2_.length)
  228.       {
  229.          if(_loc2_[_loc1_] == "..")
  230.          {
  231.             _loc2_.splice(_loc1_ - 1,2);
  232.             _loc1_ = Math.max(-1,_loc1_ - 2);
  233.          }
  234.          else if(_loc2_[_loc1_] == "." || !_loc2_[_loc1_] || _loc2_[_loc1_] == "")
  235.          {
  236.             _loc2_.splice(_loc1_,1);
  237.             _loc1_ = Math.max(-1,_loc1_ - 1);
  238.          }
  239.          _loc1_ = _loc1_ + 1;
  240.       }
  241.       fullPath = "/" + _loc2_.join("/");
  242.       return fullPath;
  243.    }
  244.    function onKeyDown()
  245.    {
  246.       switch(Key.getCode())
  247.       {
  248.          case 8:
  249.             if(!this.active)
  250.             {
  251.                break;
  252.             }
  253.             if(this.cursorPos - 1 >= this.promptVar.length)
  254.             {
  255.                this.input.text = this.input.text.substring(0,this.cursorPos - 1) + this.input.text.substring(this.cursorPos,this.input.text.length);
  256.                this.updateCursor(-1);
  257.             }
  258.             break;
  259.          case 9:
  260.             if(!this.active)
  261.             {
  262.                break;
  263.             }
  264.             var _loc6_ = this.input.text.substring(this.promptVar.length,this.cursorPos);
  265.             var _loc10_ = this.input.text.lastIndexOf(" ",this.cursorPos);
  266.             if(_loc10_ != -1)
  267.             {
  268.                _loc6_ = this.input.text.substring(_loc10_ + 1,this.input.text.length + 1);
  269.             }
  270.             var _loc13_ = (this.ram.CWD + "/" + _loc6_).split("/");
  271.             var _loc7_ = String(_loc13_.pop());
  272.             var _loc14_ = _loc13_.join("/");
  273.             var _loc8_ = this.getObjectAtPath(_loc14_);
  274.             var _loc3_ = new Array();
  275.             for(var _loc4_ in _global.bin)
  276.             {
  277.                if(_loc4_.substr(0,_loc6_.length) == _loc6_ && !_loc3_[_loc4_])
  278.                {
  279.                   _loc3_.push(_loc4_);
  280.                   _loc3_[_loc4_] = true;
  281.                }
  282.             }
  283.             for(_loc4_ in _loc8_)
  284.             {
  285.                if(_loc4_.substr(0,_loc7_.length) == _loc7_ && !_loc3_[_loc4_])
  286.                {
  287.                   _loc3_.push(_loc4_);
  288.                   _loc3_[_loc4_] = true;
  289.                }
  290.             }
  291.             if(_loc3_.length == 1)
  292.             {
  293.                this.insertAtCursor(_loc3_[0].substring(_loc7_.length,_loc3_[0].length));
  294.             }
  295.             else if(_loc3_.length > 1)
  296.             {
  297.                this.stdout();
  298.                var _loc5_ = _loc3_[0].length;
  299.                _loc4_ = 0;
  300.                while(_loc4_ < _loc3_.length)
  301.                {
  302.                   this.stdout(_loc3_[_loc4_]);
  303.                   while(_loc3_[_loc4_].substr(0,_loc5_) != _loc3_[0].substr(0,_loc5_))
  304.                   {
  305.                      _loc5_ = _loc5_ - 1;
  306.                   }
  307.                   _loc4_ = _loc4_ + 1;
  308.                }
  309.                if(_loc5_)
  310.                {
  311.                   this.insertAtCursor(_loc3_[0].substring(_loc7_.length,Math.min(_loc5_,_loc3_[0].length)));
  312.                }
  313.             }
  314.             break;
  315.          case 13:
  316.             if(this.active)
  317.             {
  318.                var _loc9_ = this.input.text.substring(this.promptVar.length,this.input.text.length);
  319.                this.history.unshift(_loc9_);
  320.                if(this.history.length > this.historyLen)
  321.                {
  322.                   this.history.pop();
  323.                }
  324.                this.historyPtr = -1;
  325.                this.stdout(this.promptVar + _loc9_);
  326.                this.stdout(this.executeCommand(_loc9_));
  327.                this.input.text = this.promptVar;
  328.                this.updatePrompt();
  329.                this.updateCursor();
  330.             }
  331.             if(this.active)
  332.             {
  333.                Selection.setFocus(this.mc.input);
  334.                Selection.setSelection(0,0);
  335.             }
  336.             break;
  337.          case 16:
  338.          case 17:
  339.          case 18:
  340.          case 20:
  341.             break;
  342.          case 35:
  343.             this.cursorPos = this.input.text.length;
  344.             this.updateCursor();
  345.             break;
  346.          case 36:
  347.             this.cursorPos = 0;
  348.             this.updateCursor();
  349.             break;
  350.          case 37:
  351.             if(!this.active)
  352.             {
  353.                break;
  354.             }
  355.             this.updateCursor(-1);
  356.             break;
  357.          case 38:
  358.             if(!this.active)
  359.             {
  360.                break;
  361.             }
  362.             this.historyPtr = Math.min(this.history.length - 1,this.historyPtr + 1);
  363.             this.input.text = this.promptVar + this.history[this.historyPtr];
  364.             this.cursorPos = this.input.text.length;
  365.             this.updateCursor();
  366.             break;
  367.          case 39:
  368.             if(!this.active)
  369.             {
  370.                break;
  371.             }
  372.             this.updateCursor(1);
  373.             break;
  374.          case 40:
  375.             if(!this.active)
  376.             {
  377.                break;
  378.             }
  379.             this.historyPtr = Math.max(-1,this.historyPtr - 1);
  380.             if(this.historyPtr == -1)
  381.             {
  382.                this.input.text = this.promptVar;
  383.             }
  384.             else
  385.             {
  386.                this.input.text = this.promptVar + this.history[this.historyPtr];
  387.             }
  388.             this.cursorPos = this.input.text.length;
  389.             this.updateCursor();
  390.             break;
  391.          case 46:
  392.             if(!this.active)
  393.             {
  394.                break;
  395.             }
  396.             this.input.text = this.input.text.substring(0,this.cursorPos) + this.input.text.substring(this.cursorPos + 1,this.input.text.length);
  397.             break;
  398.          case 220:
  399.             if(this.active)
  400.             {
  401.                this.hide();
  402.             }
  403.             else
  404.             {
  405.                this.show();
  406.             }
  407.             break;
  408.          default:
  409.             if(!this.active)
  410.             {
  411.                break;
  412.             }
  413.             var _loc11_ = Key.getCode() + (!(Key.isDown(16) || Key.isToggled(20)) ? 0 : 256) + (!Key.isDown(17) ? 0 : 512) + (!Key.isDown(18) ? 0 : 1024);
  414.             var _loc15_ = Key.getAscii();
  415.             var _loc12_ = undefined;
  416.             if(this.codepage[_loc11_])
  417.             {
  418.                _loc12_ = this.codepage[_loc11_];
  419.             }
  420.             else
  421.             {
  422.                _loc12_ = String.fromCharCode(_loc15_);
  423.             }
  424.             this.insertAtCursor(_loc12_);
  425.             Selection.setFocus(this.mc.input);
  426.             Selection.setSelection(2,2);
  427.             break;
  428.       }
  429.    }
  430.    function redraw()
  431.    {
  432.       this.mc.lineStyle(0,com.neodelight.flanix.Console.COLOR_LINE);
  433.       this.mc.moveTo(this.offsetX,this.offsetY);
  434.       this.mc.beginFill(com.neodelight.flanix.Console.COLOR_BG,com.neodelight.flanix.Console.COLOR_BG_ALPHA);
  435.       this.mc.lineTo(this.width + this.offsetX,this.offsetY);
  436.       this.mc.lineTo(this.width + this.offsetX,this.height + this.offsetY);
  437.       this.mc.lineTo(this.offsetX,this.height + this.offsetY);
  438.       this.mc.lineTo(this.offsetX,this.offsetY);
  439.       this.mc.endFill();
  440.       this.output._x = this.offsetX;
  441.       this.output._y = this.offsetY;
  442.       this.input._x = this.padding + this.offsetX;
  443.       this.input._y = this.padding + this.offsetY + this.outputHeight + this.spacing;
  444.       this.updatePrompt();
  445.       this.updateCursor();
  446.    }
  447.    function updateCursor(offset)
  448.    {
  449.       if(offset)
  450.       {
  451.          this.cursorPos += offset;
  452.       }
  453.       this.cursorPos = Math.max(this.promptVar.length,Math.min(this.input.text.length,this.cursorPos));
  454.       this.cursorMc._x = this.offsetX + this.padding + 2 + this.cursorPos * 8;
  455.       this.cursorMc._visible = true;
  456.    }
  457.    function updatePrompt()
  458.    {
  459.       this.promptVar = this.ram.CWD + ">";
  460.       this.input.text = this.promptVar;
  461.    }
  462.    function insertAtCursor(str)
  463.    {
  464.       this.input.text = this.input.text.substring(0,this.cursorPos) + str + this.input.text.substring(this.cursorPos,this.input.text.length);
  465.       this.updateCursor(str.length);
  466.    }
  467.    function executeCommand(cmd, stdin)
  468.    {
  469.       var _loc24_ = "";
  470.       cmd = com.neodelight.std.XString.trim(cmd);
  471.       while(cmd.charAt(cmd.length - 1) == ";")
  472.       {
  473.          cmd = cmd.substr(0,cmd.length - 1);
  474.       }
  475.       var _loc4_ = "cmd";
  476.       var _loc2_ = "";
  477.       var _loc12_ = cmd.length - 1;
  478.       for(; _loc12_ >= 0; _loc12_ = _loc12_ - 1)
  479.       {
  480.          if(cmd.charAt(_loc12_ - 1) == "\\")
  481.          {
  482.             continue;
  483.          }
  484.          var _loc3_ = cmd.charAt(_loc12_);
  485.          switch(_loc4_)
  486.          {
  487.             case "cmd":
  488.                switch(_loc3_)
  489.                {
  490.                   case "\"":
  491.                      _loc4_ = "quotDouble";
  492.                      break;
  493.                   case "\'":
  494.                      _loc4_ = "quotSingle";
  495.                      break;
  496.                   case ";":
  497.                   case "\n":
  498.                      var _loc19_ = cmd.substr(0,_loc12_);
  499.                      var _loc14_ = String(this.executeCommand(_loc19_));
  500.                      if(_loc14_ != "")
  501.                      {
  502.                         _loc24_ += _loc14_ + "\n";
  503.                      }
  504.                      cmd = cmd.substr(_loc12_ + 1);
  505.                      _loc12_ = -1;
  506.                }
  507.                break;
  508.             case "quotSingle":
  509.                if(_loc3_ == "\'")
  510.                {
  511.                   _loc4_ = "cmd";
  512.                }
  513.                break;
  514.             case "quotDouble":
  515.                if(_loc3_ == "\"")
  516.                {
  517.                   _loc4_ = "cmd";
  518.                }
  519.                break;
  520.             default:
  521.                trace("#ERROR: unknown mode: " + _loc4_ + ".. flanix is buggy");
  522.                break;
  523.          }
  524.       }
  525.       if(this.ram.CWD == undefined)
  526.       {
  527.          this.ram.CWD = "/";
  528.       }
  529.       var _loc18_ = undefined;
  530.       var _loc21_ = undefined;
  531.       var _loc11_ = new Array();
  532.       _loc2_ = "";
  533.       _loc4_ = "cmd";
  534.       cmd += " ";
  535.       _loc12_ = 0;
  536.       for(; _loc12_ < cmd.length; _loc12_ = _loc12_ + 1)
  537.       {
  538.          _loc3_ = cmd.charAt(_loc12_);
  539.          switch(_loc4_)
  540.          {
  541.             case "cmd":
  542.                if(_loc3_ == " ")
  543.                {
  544.                   _loc2_ = com.neodelight.std.XString.stripSlashes(_loc2_);
  545.                   _loc4_ = "param";
  546.                   if(_loc2_ != "")
  547.                   {
  548.                      _loc11_.push(_loc2_);
  549.                   }
  550.                   _loc2_ = "";
  551.                }
  552.                else
  553.                {
  554.                   _loc2_ += _loc3_;
  555.                }
  556.                break;
  557.             case "param":
  558.                if(_loc2_ == "")
  559.                {
  560.                   if(_loc3_ == " ")
  561.                   {
  562.                      continue;
  563.                   }
  564.                   if(_loc3_ == "`")
  565.                   {
  566.                      _loc4_ = "paramExpression";
  567.                      _loc2_ += _loc3_;
  568.                      continue;
  569.                   }
  570.                   if(_loc3_ == "\"")
  571.                   {
  572.                      _loc4_ = "paramQuoteDouble";
  573.                      continue;
  574.                   }
  575.                   if(_loc3_ == "\'")
  576.                   {
  577.                      _loc4_ = "paramQuoteSingle";
  578.                      continue;
  579.                   }
  580.                   if(_loc3_ == "|")
  581.                   {
  582.                      _loc18_ = cmd.substr(_loc12_ + 1);
  583.                      _loc21_ = "|";
  584.                      _loc12_ = 1.7976931348623157e+308;
  585.                      continue;
  586.                   }
  587.                   if(_loc3_ == ">")
  588.                   {
  589.                      _loc4_ = "paramPipeOutFile";
  590.                      continue;
  591.                   }
  592.                }
  593.                if(_loc3_ == " ")
  594.                {
  595.                   _loc4_ = "param";
  596.                   if(Number(_loc2_) == _loc2_)
  597.                   {
  598.                      _loc2_ = Number(_loc2_);
  599.                   }
  600.                   else
  601.                   {
  602.                      _loc2_ = com.neodelight.std.XString.stripSlashes(_loc2_);
  603.                      if(_loc2_.indexOf("$") != -1)
  604.                      {
  605.                         if(_loc2_.length <= _loc2_.indexOf("$") + 1)
  606.                         {
  607.                            this.stderr("bash: unknown variable: $");
  608.                            this.setExitCode(2);
  609.                            return undefined;
  610.                         }
  611.                         var _loc8_ = this.ram[_loc2_.substr(_loc2_.indexOf("$") + 1)];
  612.                         if(_loc8_ == undefined)
  613.                         {
  614.                            _loc8_ = "";
  615.                         }
  616.                         _loc2_ = _loc2_.substring(0,_loc2_.indexOf("$")) + String(_loc8_);
  617.                      }
  618.                   }
  619.                   _loc11_.push(_loc2_);
  620.                   _loc2_ = "";
  621.                }
  622.                else
  623.                {
  624.                   _loc2_ += _loc3_;
  625.                }
  626.                break;
  627.             case "paramExpression":
  628.                if(_loc3_ == "`" && cmd.charAt(_loc12_ - 1) != "\\")
  629.                {
  630.                   _loc2_ = this.executeCommand(_loc2_);
  631.                   _loc4_ = "param";
  632.                   _loc11_.push(_loc2_);
  633.                   _loc2_ = "";
  634.                }
  635.                else
  636.                {
  637.                   _loc2_ += _loc3_;
  638.                }
  639.                break;
  640.             case "paramQuoteSingle":
  641.                if(_loc3_ == "\'" && cmd.charAt(_loc12_ - 1) != "\\")
  642.                {
  643.                   _loc2_ = com.neodelight.std.XString.stripSlashes(_loc2_);
  644.                   _loc4_ = "param";
  645.                   _loc11_.push(_loc2_);
  646.                   _loc2_ = "";
  647.                }
  648.                else
  649.                {
  650.                   _loc2_ += _loc3_;
  651.                }
  652.                break;
  653.             case "paramQuoteDouble":
  654.                if(_loc3_ == "\"" && cmd.charAt(_loc12_ - 1) != "\\")
  655.                {
  656.                   _loc2_ = com.neodelight.std.XString.stripSlashes(_loc2_);
  657.                   while(_loc2_.indexOf("$") != -1)
  658.                   {
  659.                      var _loc6_ = _loc2_.indexOf("$");
  660.                      var _loc10_ = Math.min(_loc2_.length,_loc2_.indexOf(" ",_loc6_) <= -1 ? 1.7976931348623157e+308 : _loc2_.indexOf(" ",_loc6_));
  661.                      var _loc13_ = _loc2_.substring(_loc6_ + 1,_loc10_);
  662.                      _loc8_ = this.ram[_loc13_];
  663.                      if(_loc8_ == undefined)
  664.                      {
  665.                         _loc8_ = "";
  666.                      }
  667.                      _loc2_ = _loc2_.slice(0,_loc6_) + String(_loc8_) + _loc2_.slice(_loc10_,_loc2_.length);
  668.                   }
  669.                   _loc4_ = "param";
  670.                   _loc11_.push(_loc2_);
  671.                   _loc2_ = "";
  672.                }
  673.                else
  674.                {
  675.                   _loc2_ += _loc3_;
  676.                }
  677.                break;
  678.             case "paramPipeOutFile":
  679.                if(!(_loc3_ == " " && _loc2_ == ""))
  680.                {
  681.                   if(_loc3_ == " ")
  682.                   {
  683.                      _loc18_ = _loc2_;
  684.                      _loc21_ = ">";
  685.                      _loc2_ = "";
  686.                      _loc4_ = "param";
  687.                   }
  688.                   else
  689.                   {
  690.                      _loc2_ += _loc3_;
  691.                   }
  692.                }
  693.                break;
  694.             default:
  695.                trace("unknown mode: " + _loc4_);
  696.                break;
  697.          }
  698.       }
  699.       var _loc22_ = "";
  700.       if(_loc11_.length)
  701.       {
  702.          var _loc7_ = new Array();
  703.          _loc12_ = 1;
  704.          while(_loc12_ < _loc11_.length)
  705.          {
  706.             _loc7_.push(_loc11_[_loc12_]);
  707.             _loc12_ = _loc12_ + 1;
  708.          }
  709.          var _loc15_ = {};
  710.          for(_loc12_ in _loc7_)
  711.          {
  712.             if(_loc7_[_loc12_].substr(0,2) == "--")
  713.             {
  714.                _loc15_[_loc7_[_loc12_].substr(2,_loc7_[_loc12_].length - 2)] = true;
  715.             }
  716.             else if(String(_loc7_[_loc12_]).substr(0,1) == "-")
  717.             {
  718.                var _loc9_ = 1;
  719.                while(_loc9_ < String(_loc7_[_loc12_]).length)
  720.                {
  721.                   _loc15_[String(_loc7_[_loc12_]).charAt(_loc9_)] = true;
  722.                   _loc9_ = _loc9_ + 1;
  723.                }
  724.             }
  725.          }
  726.          if(stdin != undefined)
  727.          {
  728.             _loc7_.push(stdin);
  729.          }
  730.          var _loc20_ = String(_loc11_[0]);
  731.          this.setExitCode(undefined);
  732.          var _loc17_ = undefined;
  733.          var _loc23_ = undefined;
  734.          if(_loc20_.indexOf("/") != -1)
  735.          {
  736.             if(_loc20_.charAt(0) == "/")
  737.             {
  738.                _loc17_ = this.getObjectAtPath(_loc20_);
  739.                _loc23_ = this.getBasePath(_loc20_);
  740.             }
  741.             else
  742.             {
  743.                _loc17_ = this.getObjectAtPath(this.ram.CWD + "/" + _loc20_);
  744.                _loc23_ = this.getBasePath(this.ram.CWD + "/" + _loc20_);
  745.             }
  746.          }
  747.          else
  748.          {
  749.             var _loc16_ = this.ram.PATH.indexOf("/bin") != -1 ? this.ram.PATH.split(":") : ("/bin:" + this.ram.PATH).split(":");
  750.             _loc12_ = 0;
  751.             while(_loc12_ < _loc16_.length)
  752.             {
  753.                _loc17_ = this.getObjectAtPath(_loc16_[_loc12_] + "/" + _loc20_);
  754.                if(_loc17_ != undefined)
  755.                {
  756.                   _loc23_ = _loc16_[_loc12_];
  757.                   break;
  758.                }
  759.                _loc12_ = _loc12_ + 1;
  760.             }
  761.          }
  762.          if(_loc17_ != undefined)
  763.          {
  764.             switch(typeof _loc17_)
  765.             {
  766.                case "function":
  767.                   var _loc27_ = Function(_loc17_);
  768.                   this.parameters = _loc7_;
  769.                   this.flags = _loc15_;
  770.                   _loc22_ = _loc27_.apply(this.getObjectAtPath(_loc23_),_loc7_);
  771.                   break;
  772.                case "string":
  773.                   var _loc25_ = _loc17_.split("\n",2);
  774.                   if(_loc25_[0] == "#!/bin/sh")
  775.                   {
  776.                      _loc22_ = this.executeCommand(_loc25_[1]);
  777.                   }
  778.                   else
  779.                   {
  780.                      this.stderr("bash: to execute a string as a script, type: sh <filename>");
  781.                   }
  782.                   break;
  783.                default:
  784.                   this.stderr("bash: not a command: " + _loc20_ + " (" + typeof _loc17_ + ")");
  785.             }
  786.          }
  787.          else
  788.          {
  789.             this.stderr("bash: command not found or undefined: " + _loc20_);
  790.             this.setExitCode(3);
  791.          }
  792.          this.ram.CWD = this.simplifyPath(this.ram.CWD);
  793.          if(_loc18_)
  794.          {
  795.             switch(_loc21_)
  796.             {
  797.                case "|":
  798.                   _loc22_ = this.executeCommand(_loc18_,_loc22_);
  799.                   break;
  800.                case ">":
  801.                   if(_loc18_.indexOf("/") != -1)
  802.                   {
  803.                      var _loc26_ = this.getObjectAtPath(this.getBasePath(_loc18_));
  804.                      _loc26_[this.getFileName(_loc18_)] = _loc22_;
  805.                   }
  806.                   else
  807.                   {
  808.                      _loc26_ = this.getObjectAtCwd();
  809.                      _loc26_[_loc18_] = _loc22_;
  810.                   }
  811.                   break;
  812.                case "<":
  813.             }
  814.             _loc22_ = "";
  815.          }
  816.       }
  817.       else
  818.       {
  819.          _loc22_ = "";
  820.       }
  821.       return _loc24_ + _loc22_;
  822.    }
  823. }
  824.