@param array|string $command
@param string|null  $cwd

@return self
19887
public static function fromStringCommand($command, $cwd = null)
    {
        if (\method_exists(SymfonyProcess::class, 'fromShellCommandline')) {
            $process = SymfonyProcess::fromShellCommandline($command, $cwd);
        } else {
            $process = new SymfonyProcess($command, $cwd);
        }

        if (\method_exists(SymfonyProcess::class, 'inheritEnvironmentVariables')) {
            $process->inheritEnvironmentVariables(true);
        }

        return new self($process);
    }
240834
public function run(
        ?string $command,
        $input = [],
        OutputInterface $output = null
    ): CommandOutput {
        if (is_array($input)) {
            $input = new ArrayInput($input + compact('command'));
        }
        $output = $output ?? new BufferedOutput();

        $command = $this->getApplication()->find($command);
        $code = ContainerScope::runScope($this->container, function () use (
            $command,
            $input,
            $output
        ) {
            return $command->run($input, $output);
        });

        return new CommandOutput($code ?? self::CODE_NONE, $output);
    }
465340
public function command(ConsoleCommandEvent $event)
    {
        /** @var ManifestCommand $command */
        $command = $event->getCommand();

        if (!in_array($command->getName(), $this->getSupportedCommands())) {
            return;
        }

        $command->setChain($this->chain);

        if ($command instanceof RunCommand) {
            $command->setEventDispatcher($this->dispatcher);
        }
    }
859185
public function exec($command, $callback = null)
    {
        $this->commandStack[] = [
            'command' => new Command($this->receiveCommand($command)),
            'callback' => $callback,
        ];

        return $this;
    }
130078
function unload($cwd) {
		chdir($cwd);
		if (!($error=error_get_last()) &&
			session_status()==PHP_SESSION_ACTIVE)
			session_commit();
		foreach ($this->locks as $lock)
			@unlink($lock);
		$handler=$this->hive['UNLOAD'];
		if ((!$handler || $this->call($handler,$this)===FALSE) &&
			$error && in_array($error['type'],
			[E_ERROR,E_PARSE,E_CORE_ERROR,E_COMPILE_ERROR]))
			// Fatal error detected
			$this->error(500,
				sprintf(self::E_Fatal,$error['message']),[$error]);
	}
776384
public function setCommand($command, $base = null)
    {

        $base = ($base === null) ? BASE : $base;

        parent::setCommand($this->resolveBase($base).'anonym '.$command);
        return $this;
    }
1219783
function execute (str, { cwd }) {
  // command = replace(command, options);
  // command = prepend(command, options);

  let args = str.split(' ')
  const command = args.shift()
  args = [args.join(' ')]

  const subprocess = spawn(command, args, {
    detached: true,
    stdio: 'ignore',
    cwd
  })

  subprocess.unref()

  return subprocess.pid
}
285405
public function execute($command, $cwd = null)
    {
        if (strpos($command, '<') === 0) {
            return array(true, trim($command, '< '));
        }
        
        $processExecutor = $this->getProcessExecutor();

        $logger = $this->logger;

        $output = '';
        
        $outputHandler = function ($type, $data) use ($logger, &$output) {
            $output .= $data;
            
            $logger->writeVerbose('comment', trim($data));
        };
        
        if ($this->logger->getOutputInstance()->isVerbose()) {
            $this->logger->writeIndentation();
        }
        
        $result = $processExecutor->execute($command, $outputHandler, $cwd);

        return array($result === 0, $output);
    }
470124
public function callSilent($command, array $arguments = []) {
		$instance = $this->getApplication()->find($command);
		$arguments['command'] = $command;

		return $instance->run(new ArrayInput($arguments), new NullOutput);
	}
35639
public function prepare($command)
    {
        // change path for php
        if (substr($command, 0, 4) == 'php ') {
            $command = $this->finder->getPath().substr($command, 3);
        }

        // change path to console
        $command = str_replace(' app/console ', ' '.$this->console.' ', $command);

        // change /dev/null for Windows
        if (defined('PHP_WINDOWS_VERSION_BUILD')) {
            $command = str_replace('/dev/null', 'nul', $command);
        }

        return $command;
    }
547018
protected function createCommand($commandName, array $commandDca)
    {

        $command = $this->createCommandInstance($commandName, $commandDca);
        $command->setName($commandName);

        $parameters = $command->getParameters();

        if (isset($commandDca['href'])) {
            \parse_str($commandDca['href'], $queryParameters);
            foreach ($queryParameters as $name => $value) {
                $parameters[$name] = $value;
            }
            unset($commandDca['href']);
        }

        if (isset($commandDca['parameters'])) {
            foreach ($commandDca['parameters'] as $name => $value) {
                $parameters[$name] = $value;
            }
            unset($commandDca['parameters']);
        }

        if (isset($commandDca['label'])) {
            $lang = $commandDca['label'];

            if (\is_array($lang)) {
                $label       = \reset($lang);
                $description = \next($lang);

                $command->setDescription($description);
            } else {
                $label = $lang;
            }

            $command->setLabel($label);

            unset($commandDca['label']);
        }

        if (isset($commandDca['description'])) {
            $command->setDescription($commandDca['description']);

            unset($commandDca['description']);
        }

        // Callback is transformed into event in parseCallbacks().
        unset($commandDca['button_callback']);

        if (\count($commandDca)) {
            $extra = $command->getExtra();

            foreach ($commandDca as $name => $value) {
                $extra[$name] = $value;
            }
        }

        return $command;
    }
1200018
public function addCommands(array $commands)
    {
        foreach ($commands as $name => $command) {
            $this->addCommand($command, is_numeric($name) ? null : $name);
        }
        return $this;
    }
157494
public function setCwd($cwd)
    {
        $this->hasCheckout = false;
        $this->hasClone = false;
        $this->isTemporary = false;

        if (is_null($cwd)) {
            $this->cwd = sys_get_temp_dir() . '/' . uniqid('git');

            // ensure the working directory exists (needed on windows)
            if (!is_dir($this->cwd)) {
                mkdir($this->cwd);
            }

            $this->isTemporary = true;
        } else {
            if (is_dir($cwd)) {
                if (is_dir($cwd . '/.git')) {
                    $this->hasClone = true;
                }
            }
            $this->cwd = $cwd;
        }

        return $this;
    }
773886
final public function execute($command, AnCommandContext $context)
    {
        $identifier = $context->caller->getIdentifier();

        if ($context->entity instanceof AnDomainEntityAbstract) {
            $identifier = $context->entity->getIdentifier();
        }

        $type = $identifier->path;
        $type = array_pop($type);

        $parts = explode('.', $command);
        $method = '_'.($parts[0]).ucfirst($type).ucfirst($parts[1]);

        $result = null;

        if (method_exists($this, $method)) {
            $result = $this->$method($context);
        }

        if ($context->entity) {
            $result = $context->entity->execute($command, $context);
        }

        return $result;
    }
15286
private function composeProcess(string $command): Process
    {
        if ($this->process === null) {
            $this->process = new Process([$command]);
        }

        $this->process->inheritEnvironmentVariables();
        $this->process->setTimeout($this->timeout);
        $this->process->setCommandLine($command);

        return $this->process;
    }
1187536
function (cmd, cwd) {
      return execute(cmd, cwd ? path.resolve(target, cwd) : target)
    }
10311
public function bind($command)
    {
        $this->command = $command;
        $this->config = $command->getApplication()->config();
        $this->init();

        return $this;
    }