@param string $command

@return array
13970
public function exec( $command ) {
		$command .= ' 2>&1';
		$command = escapeshellcmd( $command );
		exec( $command, $output, $return_var );

		return [ $output, $return_var ];
	}
914343
public function profileCommand($command) {
		$tasks = $this->Task->find('all', array(
			'conditions' => array(
				'command' => $command,
				'status' => array(TaskType::STOPPED, TaskType::FINISHED),
				'runtime >' => 0
			),
			'fields' => array('runtime', 'id', 'started', 'stopped', 'created', 'waittime'),
			'limit' => Configure::read('Task.profilerLimit'),
			'order' => array(
				'id' => 'DESC'
			)
		));

		if (!$tasks) {
			return null;
		}

		$statistics = array_map(function($item) {
			$endDate = new DateTime($item['stopped']);
			$startDate = new DateTime($item['started']);
			$createdDate = new DateTime($item['created']);
			$item['runtimeHuman'] = $startDate->diff($endDate)->format(Configure::read('Task.dateDiffFormat'));
			$item['waittimeHuman'] = $createdDate->diff($startDate)->format(Configure::read('Task.dateDiffFormat'));
			$item['startedTimestamp'] = $startDate->getTimestamp();
			$item['runtime'] = (int)$item['runtime'];
			$item['waittime'] = (int)$item['waittime'];
			return $item;
		}, Hash::extract($tasks, '{n}.{s}'));
		
		$runtimes = Hash::extract($statistics, '{n}.runtime');
		$runtimeAverage = (int)round($runtimes ? array_sum($runtimes) / count($runtimes) : 0);
		$runtimeMax = $runtimes ? max($runtimes) : 0;
		$runtimeMin = $runtimes ? min($runtimes) : 0;

		$waittimes = Hash::extract($statistics, '{n}.waittime');
		$waittimeAverage = (int)round($waittimes ? array_sum($waittimes) / count($waittimes) : 0);
		$waittimeMax = $waittimes ? max($waittimes) : 0;
		$waittimeMin = $waittimes ? min($waittimes) : 0;

		$countByStatus = array();
		foreach (TaskType::getTypes() as $statusCode) {
			$countByStatus[$statusCode] = $this->Task->find('count', array(
				'conditions' => array(
					'command' => $command,
					'status' => $statusCode
				)
			));
		}

		$errored = $this->Task->find('count', array(
			'conditions' => array(
				'command' => $command,
				'errored' => true
			)
		));

		return array(
			'command' => $command,
			'countByStatus' => $countByStatus,
			'errored' => $errored,
			'statistics' => $statistics,
			'runtimeAverage' => $runtimeAverage,
			'runtimeAverageHuman' => $this->_secondsToHuman($runtimeAverage),
			'runtimeMax' => $runtimeMax,
			'runtimeMaxHuman' => $this->_secondsToHuman($runtimeMax),
			'runtimeMin' => $runtimeMin,
			'runtimeMinHuman' => $this->_secondsToHuman($runtimeMin),
			'waittimeAverage' => $waittimeAverage,
			'waittimeAverageHuman' => $this->_secondsToHuman($waittimeAverage),
			'waittimeMax' => $waittimeMax,
			'waittimeMaxHuman' => $this->_secondsToHuman($waittimeMax),
			'waittimeMin' => $waittimeMin,
			'waittimeMinHuman' => $this->_secondsToHuman($waittimeMin),
		);
	}
1327031
private function getOutputFilterRegex($command)
    {
        $commandCharacters = str_split(preg_quote($command, '/'));
        $commandCharacterRegexWhitespaceFunction = function ($value) {
            if ($value !== '\\') {
                $value .= '\s?';
            }

            return $value;
        };

        $commandCharacters = array_map($commandCharacterRegexWhitespaceFunction, $commandCharacters);

        return sprintf('/%s(.*)%s/s', implode('', $commandCharacters), substr($this->getShellPromptRegex(), 1, -1));
    }
1225703
public function get($command = null)
    {
        if (isset($command)) {
            $routes = $this->getList();
            return isset($routes[$command]) ? $routes[$command] : array();
        }

        return $this->route;
    }
643423
protected static function execute($command)
    {
        $res = array();

        ob_start();
        passthru($command, $success);
        $output = ob_get_clean();

        foreach ((explode("\n", $output)) as $line) $res[] = trim($line);

        return array_filter($res);
    }
81631
protected function doAction(Command $command)
    {
        if ($command->name() === '__default__') {
            return $this->notFound();
        }

        // Let the command collect more data (if missing or needs confirmation)
        $command->interact($this->io());

        if (!$command->action() && !\method_exists($command, 'execute')) {
            return;
        }

        $params = [];
        $values = $command->values();
        // We prioritize action to be in line with commander.js!
        $action = $command->action() ?? [$command, 'execute'];

        foreach ($this->getActionParameters($action) as $param) {
            $params[] = $values[$param->getName()] ?? null;
        }

        return $action(...$params);
    }
1196850
public function match(Command $command)
    {
        if ($this->isEmpty()) {
            return false;
        }
        if ($this->isRegExp()) {
            return 1 === preg_match($this->getName(), $command->getName());
        }
        return $command->getName() === $this->getName();
    }
335270
public function command($command)
    {
        $attributes = AnConfig::unbox($command->getAttributes());

        if (isset($attributes['icon'])) {
            $icon = 'icon-'.$attributes['icon'];
            $command->label = '<i class="'.$icon.'"></i>&nbsp;'.$command->label;
            unset($attributes['icon']);
        }

        $html = $this->getService('com:base.template.helper.html');

        return (string) $html->tag('a', $command->label, $attributes);
    }
114443
private function execCommand(array $command): array
  {
    $this->logVerbose('Execute: %s', implode(' ', $command));
    list($output, $ret) = ProgramExecution::exec1($command, null);
    if ($ret!=0)
    {
      foreach ($output as $line)
      {
        $this->logInfo($line);
      }
      $this->logError("Error executing '%s'.", implode(' ', $command));
    }
    else
    {
      foreach ($output as $line)
      {
        $this->logVerbose($line);
      }
    }

    return $output;
  }
886131
protected function getKeyFromScriptingCommands(CommandInterface $command)
    {
        if ($command instanceof ScriptCommand) {
            $keys = $command->getKeys();
        } else {
            $keys = array_slice($args = $command->getArguments(), 2, $args[1]);
        }

        if ($keys && $this->checkSameSlotForKeys($keys)) {
            return $keys[0];
        }
    }
250729
public function getRoute($command)
    {
        if (!isset($this->routes[$command])) {
            return null;
        }
        
        return $this->routes[$command];
    }
260875
private static function runCommand($command)
    {
        if (!function_exists('proc_open')) {
            return null;
        }

        $descriptorSpec = [
            1 => ['pipe', 'w'],
            2 => ['pipe', 'w'],
        ];
        $process = proc_open($command, $descriptorSpec, $pipes, null, null, ['suppress_errors' => true]);
        if (!is_resource($process)) {
            return null;
        }

        $info = stream_get_contents($pipes[1]);
        fclose($pipes[1]);
        fclose($pipes[2]);
        proc_close($process);

        return $info;
    }
575247
public function getCommandHandler($command)
    {
        if ($this->hasCommandHandler($command)) {
            return $this->container->make($this->handlers[get_class($command)]);
        }

        return false;
    }
1264962
public function dispatch(CommandInterface $command)
    {
        $this->commandStack[] = $command;

        if ($this->executing) {
            return array();
        }

        $first          = true;
        $aggregateRoots = array();

        while ($command = array_shift($this->commandStack)) {
            $aggregateRoots[] = $this->invokeHandler($command, $first);
            $first            = false;
        }

        return $aggregateRoots;
    }
601163
public static function run(string $command, string $cwd = null): array
    {
        return Sys::run($command, $cwd);
    }
1233944
protected function getSvnCredetials($command)
    {
        $httpBasic = $this->config->get('http-basic');
        $parsedUrl = parse_url($this->baseUrl);
        $svnCommand = $command;

        if ($parsedUrl && isset($httpBasic[$parsedUrl['host']])) {
            if ($httpBasic[$parsedUrl['host']]['username'] && $httpBasic[$parsedUrl['host']]['password']) {
                $uname = $httpBasic[$parsedUrl['host']]['username'];
                $pw = $httpBasic[$parsedUrl['host']]['password'];

                $svnCommand = $command.sprintf(' --username %s --password %s --no-auth-cache', $uname, $pw);
            }
        }

        return $svnCommand;
    }
1073509
public function run(string $command) : int
    {
        $output = [];
        $returnVar = 1;

        $command .= $this->isWindows() ? $this->STD_ERR_PIPE_WIN : $this->STD_ERR_PIPE;

        exec($command, $output, $returnVar);

        return $returnVar;
    }