Page MenuHomePhorge

function csprintf($pattern, ...)
libphutil Technical Documentation ()

Format a shell command string. This function behaves like sprintf, except that all the normal conversions (like "%s") will be properly escaped, and additional conversions are supported:

%Ls
  List of strings that will be escaped. They will be space separated.

%LR
  List of "readable" strings. They will be space separated.

%P
  Password (or other sensitive parameter) to escape. Pass a
  @{class:PhutilOpaqueEnvelope}.

%C (Raw Command)
  Passes the argument through without escaping. Dangerous!

%R
  A more "readable" version of "%s". This will try to print the command
  without any escaping if it contains only characters which are safe
  in any context. The intent is to produce prettier human-readable
  commands.

Generally, you should invoke shell commands via execx() rather than by calling csprintf() directly.

Parameters
string$patternsprintf()-style format string.
...Zero or more arguments.
Return
PhutilCommandStringFormatted string, escaped appropriately for shell contexts.