Documentation ¶
Overview ¶
Package shell contains functions for quoting arguments to commands.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func QuoteUnix ¶
QuoteUnix takes an array of strings representing individual arguments of a command and returns a space-delimited sequence of double-quoted string literals quoted correctly for any POSIX-compatible shell.
It does not produce pretty output. QuoteUnix("a", "cool", "bear") becomes `"a" "cool" "bear"`, not `a cool bear`. This behavior simplifies the implementaiton, but also bypasses aliases if we are handing our string to a login shell.
QuoteUnix(s) is a valid UTF-8 string if and only if s is a valid UTF-8 string. Proof of this fact is left as an exercise to the reader.
When given a single argument s, QuoteUnix(s) quotes that argument alone.
When given multiple arguments, QuoteUnix(...) produces a space delimited sequence of quoted strings, which is interpreted as a command with arguments by every POSIX-compatible shell.
See https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html for more information.
Types ¶
This section is empty.