WP_CLI::launch
Launch an arbitrary external process that takes over I/O.
# `wp core download` falls back to the `tar` binary when PharData isn't available
if ( ! class_exists( 'PharData' ) ) {
$cmd = "tar xz --strip-components=1 --directory=%s -f $tarball";
WP_CLI::launch( Utils\esc_cmd( $cmd, $dest ) );
return;
}
Method of the class: WP_CLI{}
No Hooks.
Returns
Int|ProcessRun. The command exit status, or a ProcessRun object for full details.
Usage
$result = WP_CLI::launch( $command, $exit_on_error, $return_detailed );
- $command(string) (required)
- External process to launch.
- $exit_on_error(true|false)
- Whether to exit if the command returns an elevated return code.
Default:true - $return_detailed(true|false)
- Whether to return an exit status (default) or detailed execution results.
Default:false
WP_CLI::launch() WP CLI::launch code WP-CLI 2.13.0-alpha
public static function launch( $command, $exit_on_error = true, $return_detailed = false ) {
Utils\check_proc_available( 'launch' );
$proc = Process::create( $command );
$results = $proc->run();
if ( -1 === $results->return_code ) {
self::warning( "Spawned process returned exit code {$results->return_code}, which could be caused by a custom compiled version of PHP that uses the --enable-sigchild option." );
}
if ( $results->return_code && $exit_on_error ) {
exit( $results->return_code );
}
if ( $return_detailed ) {
return $results;
}
return $results->return_code;
}