WP_CLI\Utils

esc_cmd()WP-CLI 1.0

Given a template string and an arbitrary number of arguments, returns the final command, with the parameters escaped.

No Hooks.

Return

null. Nothing (null).

Usage

esc_cmd( $cmd );
$cmd (required)
-

esc_cmd() code WP-CLI 2.8.0-alpha

function esc_cmd( $cmd ) {
	if ( func_num_args() < 2 ) {
		trigger_error( 'esc_cmd() requires at least two arguments.', E_USER_WARNING );
	}

	$args = func_get_args();

	$cmd = array_shift( $args );

	return vsprintf( $cmd, array_map( 'escapeshellarg', $args ) );
}