public static function removeFlagFromCommands($text, $command, $full_flag) { foreach (BashInterpreter::matchCommand($text, $command) as $match) { $text = BashInterpreter::removeFlagFromCommand($text, $match, $full_flag); } return $text; }
private function removeBuildOrDownloadCommand($command) { $output_matches = BashInterpreter::matchFlag($command, "-o"); $this->task = BashInterpreter::removeCommand($this->task, $command); if (count($output_matches) == 0) { // If there was no output dir specified, remove all executes where no engine dir is given. // or where the default 'output' dir is specified. $commands = BashInterpreter::matchCommand($this->task, "python execute.py"); foreach ($commands as $command) { $engine_matches = BashInterpreter::matchFlag($command, "-e"); if (count($engine_matches) == 0) { $this->task = BashInterpreter::removeCommand($this->task, $command); continue; } foreach ($engine_matches as $engineDir) { if (BashInterpreter::sameDir($engineDir, "output")) { $this->task = BashInterpreter::removeFlagFromCommand($this->task, $command, "-e " . $engineDir); if (count($engine_matches) == 1) { $this->task = BashInterpreter::removeCommand($this->task, $command); } } } } } else { $outputDir = $output_matches[0]; $commands = BashInterpreter::matchCommand($this->task, "python execute.py"); foreach ($commands as $command) { $engine_matches = BashInterpreter::matchFlag($command, "-e"); foreach ($engine_matches as $engineDir) { if (BashInterpreter::sameDir($engineDir, $outputDir)) { $this->task = BashInterpreter::removeFlagFromCommand($this->task, $command, "-e " . $engineDir); if (count($engine_matches) == 1) { $this->task = BashInterpreter::removeCommand($this->task, $command); } } } } } }