* @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}");
}
print $this->progress($data, 0);
} else {
if ($verbose) {
- printf("%s\n", $data);
+ printf("%s", $data);
}
$this->output .= $data;
}
* @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]);
}
/**