Changeset View
Changeset View
Standalone View
Standalone View
src/xsprintf/csprintf.php
Show All 23 Lines | |||||
* in any context. The intent is to produce prettier human-readable | * in any context. The intent is to produce prettier human-readable | ||||
* commands. | * commands. | ||||
* | * | ||||
* Generally, you should invoke shell commands via @{function:execx} rather | * Generally, you should invoke shell commands via @{function:execx} rather | ||||
* than by calling @{function:csprintf} directly. | * than by calling @{function:csprintf} directly. | ||||
* | * | ||||
* @param string sprintf()-style format string. | * @param string sprintf()-style format string. | ||||
* @param ... Zero or more arguments. | * @param ... Zero or more arguments. | ||||
* @return string Formatted string, escaped appropriately for shell contexts. | * @return PhutilCommandString Formatted string, escaped appropriately for | ||||
* shell contexts. | |||||
*/ | */ | ||||
function csprintf($pattern /* , ... */) { | function csprintf($pattern /* , ... */) { | ||||
$args = func_get_args(); | $args = func_get_args(); | ||||
return new PhutilCommandString($args); | return new PhutilCommandString($args); | ||||
} | } | ||||
/** | /** | ||||
* Version of @{function:csprintf} that takes a vector of arguments. | * Version of @{function:csprintf} that takes a vector of arguments. | ||||
* | * | ||||
* @param string sprintf()-style format string. | * @param string sprintf()-style format string. | ||||
* @param list List of zero or more arguments to csprintf(). | * @param list List of zero or more arguments to csprintf(). | ||||
* @return string Formatted string, escaped appropriately for shell contexts. | * @return PhutilCommandString Formatted string, escaped appropriately for | ||||
* shell contexts. | |||||
*/ | */ | ||||
function vcsprintf($pattern, array $argv) { | function vcsprintf($pattern, array $argv) { | ||||
array_unshift($argv, $pattern); | array_unshift($argv, $pattern); | ||||
return call_user_func_array('csprintf', $argv); | return call_user_func_array('csprintf', $argv); | ||||
} | } | ||||
/** | /** | ||||
* @{function:xsprintf} callback for @{function:csprintf}. | * @{function:xsprintf} callback for @{function:csprintf}. | ||||
▲ Show 20 Lines • Show All 86 Lines • Show Last 20 Lines |