WP_CLI\Utils

force_env_on_nix_systems()WP-CLI 1.0

Maybe prefix command string with "/usr/bin/env". Removes (if there) if Windows, adds (if not there) if not.

No Hooks.

Return

String.

Usage

force_env_on_nix_systems( $command );
$command(string) (required)
-

force_env_on_nix_systems() code WP-CLI 2.7.0-alpha

function force_env_on_nix_systems( $command ) {
	$env_prefix     = '/usr/bin/env ';
	$env_prefix_len = strlen( $env_prefix );
	if ( is_windows() ) {
		if ( 0 === strncmp( $command, $env_prefix, $env_prefix_len ) ) {
			$command = substr( $command, $env_prefix_len );
		}
	} elseif ( 0 !== strncmp( $command, $env_prefix, $env_prefix_len ) ) {
		$command = $env_prefix . $command;
	}
	return $command;
}