private static function pass_through_pager($out) { if (Utils\is_windows()) { // no paging for Windows cmd.exe; sorry echo $out; return 0; } // convert string to file handle $fd = fopen("php://temp", "r+"); fputs($fd, $out); rewind($fd); $descriptorspec = array(0 => $fd, 1 => STDOUT, 2 => STDERR); return proc_close(proc_open('less -r', $descriptorspec, $pipes)); }
private static function pass_through_pager($out) { if (Utils\is_windows() || (bool) Terminus::get_config('bash') || (bool) Terminus::get_config('json')) { // No paging for Windows cmd.exe; sorry Terminus::print_value($out); return 0; } // convert string to file handle $fd = fopen("php://temp", "r+"); fputs($fd, $out); rewind($fd); $descriptorspec = array(0 => $fd, 1 => STDOUT, 2 => STDERR); return proc_close(proc_open('less -r', $descriptorspec, $pipes)); }
/** * Launch an external process that takes over I/O. * * @param string Command to call * @param bool Whether to exit if the command returns an error status * * @return int The command exit status */ static function launch($command, $exit_on_error = true) { if (Utils\is_windows()) { $command = '"' . $command . '"'; } $r = proc_close(proc_open($command, array(STDIN, STDOUT, STDERR), $pipes)); if ($r && $exit_on_error) { exit($r); } return $r; }