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((string)shell_exec("cd ${directory}; git branch | grep \\* | cut -d ' ' -f2"))."'";



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

            $branch = 'current branch';