shell_exec

Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Execute command via shell and return the complete output as a string
<?php shell_exec(string $command): string|false|null
<?php     protected function getCurrentBranch(string $directory): string

    {

        $branch = "'".trim(shell_exec("cd ${directory}; git branch | grep \\* | cut -d ' ' -f2"))."'";



        if (! isset($branch) || $branch === "''") {

            $branch = 'current branch';
<?php     protected function getCurrentBranch(string $directory): string

    {

        $branch = "'".trim((string)shell_exec("cd ${directory}; git branch | grep \\* | cut -d ' ' -f2"))."'";



        if ($branch === "''") {

            $branch = 'current branch';
<?php             return [1, 1];

        }



        $sttyMode = shell_exec('stty -g');

        shell_exec('stty -icanon -echo');



        @fwrite($input, terminal()->getCsi() . '6n');
<?php         }



        $sttyMode = shell_exec('stty -g');

        shell_exec('stty -icanon -echo');



        @fwrite($input, terminal()->getCsi() . '6n');
<?php         $code = trim(fread($input, 1024));



        shell_exec(sprintf('stty %s', $sttyMode));



        sscanf($code, terminal()->getCsi() . '%d;%dR', $row, $col);