pike.git / lib / modules / Process.pmod

version» Context lines:

pike.git/lib/modules/Process.pmod:332:   //!   string sh_quote(string s)   {    return replace(s,    ({"\\", "'", "\"", " "}),    ({"\\\\", "\\'", "\\\"","\\ "}));   }      array(string) split_quoted_string(string s, int(0..1)|void nt_mode)   //! Splits the given string into a list of arguments, according to - //! common command line quoting rules: + //! common (i.e. @expr{/bin/sh@}-based) command line quoting rules:   //!   //! @ul   //! @item   //! Sequences of whitespace, i.e. space, tab or newline, are treated   //! as argument separators by default.   //!   //! @item   //! Single or double quotes (@expr{'@} or @expr{"@}) can be used   //! around an argument to avoid whitespace splitting inside it. If   //! such quoted strings are used next to each other then they get
pike.git/lib/modules/Process.pmod:361:   //! quote in the middle.   //!   //! @item   //! A backslash can also be used to quote itself; i.e. @expr{\\@}   //! becomes @expr{\@}.   //!   //! @item   //! Backslashes in front of other characters are removed by default.   //! However, if the optional @[nt_mode] flag is set then they are   //! retained as-is, to work better with Windows style paths. + //! + //! @item + //! Backslashes are treated literally inside quoted strings, with + //! the exception that @expr{\"@} is treated as a literal @expr{"@} + //! inside a @expr{"@}-quoted string. It's therefore possible to + //! include a literal @expr{"@} in a @expr{"@}-quoted string, as + //! opposed to @expr{'@}-quoted strings which cannot contain a + //! @expr{'@}.   //! @endul   {    // Remove initial white-space.    sscanf(s,"%*[ \n\t]%s",s);       // Prefix interesting characters with NUL,    // and split on NUL.    s=replace(s,    ({"\"", "'", "\\", " ", "\t", "\n", "\0"}),    ({"\0\"","\0'","\0\\","\0 ","\0\t","\0\n", "\0\0"}));