X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=src%2Fpharext%2FExecCmd.php;h=f16d105dd30c808d9ab0a18ee2f26255737ce34a;hb=ca052b5308bb8c4d07458308fae1adde522a637f;hp=7e657f3d6f4bab3351988eb754d49c6639d7a032;hpb=e990b6dabecbdaf98b8d8b2173b0d697f9b2b754;p=pharext%2Fpharext diff --git a/src/pharext/ExecCmd.php b/src/pharext/ExecCmd.php index 7e657f3..f16d105 100644 --- a/src/pharext/ExecCmd.php +++ b/src/pharext/ExecCmd.php @@ -61,7 +61,7 @@ class ExecCmd * @return int exit status */ private function suExec($command, $verbose = null) { - if (!($proc = proc_open($command, [STDIN,["pipe","w"],["pipe","w"]], $pipes))) { + if (!($proc = proc_open($command, [STDIN,["pipe","w"],["pipe","w"]], $pipes, getcwd()))) { $this->status = -1; throw new Exception("Failed to run {$command}"); } @@ -94,7 +94,7 @@ class ExecCmd print $this->progress($data, 0); } else { if ($verbose) { - printf("%s\n", $data); + printf("%s", $data); } $this->output .= $data; } @@ -112,14 +112,18 @@ class ExecCmd * @return string */ private function progress($string, $flags) { - static $c = 0; - static $s = ["\\","|","/","-"]; + static $counter = 0; + static $symbols = ["\\","|","/","-"]; $this->output .= $string; + + if (false !== strpos($string, "\n")) { + ++$counter; + } return $flags & PHP_OUTPUT_HANDLER_FINAL ? " \r" - : sprintf(" %s\r", $s[$c++ % count($s)]); + : sprintf(" %s\r", $symbols[$counter % 4]); } /**