WP_CLI\Utils

proc_open_compat()WP-CLI 1.0

Works around bug in PHP, and also deals with *nix-like ENV_VAR=blah cmd environment variable prefixes.

No Hooks.

Return

resource. Command stripped of any environment variable settings.

Usage

proc_open_compat( $cmd, $descriptorspec, $pipes, $cwd, $env, $other_options );
$cmd(string) (required)
Command to execute.
$descriptorspec(array) (required)
Indexed array of descriptor numbers and their values.
$pipes (required) (passed by reference — &)
-
$cwd(string)
Initial working directory for the command.
Default: null
$env(array)
Array of environment variables.
Default: null
$other_options(array)
Array of additional options (Windows only).
Default: null

proc_open_compat() code WP-CLI 2.7.0-alpha

function proc_open_compat( $cmd, $descriptorspec, &$pipes, $cwd = null, $env = null, $other_options = null ) {
	if ( is_windows() ) {
		// Need to encompass the whole command in double quotes - PHP bug https://bugs.php.net/bug.php?id=49139
		$cmd = '"' . _proc_open_compat_win_env( $cmd, $env ) . '"';
	}
	return proc_open( $cmd, $descriptorspec, $pipes, $cwd, $env, $other_options );
}