Documentation ¶
Overview ¶
Package shellescape provides the shellescape.Quote to escape arbitrary strings for a safe use as command line arguments in the most common POSIX shells.
The original Python package which this work was inspired by can be found at https://pypi.python.org/pypi/shellescape.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Quote ¶
Quote returns a shell-escaped version of the string s. The returned value is a string that can safely be used as one token in a shell command line.
Example ¶
package main import ( "fmt" "strings" "github.com/alessio/shellescape" ) func main() { filename := "myfile; rm -rf /" prog := "/bin/ls" unescapedCommand := strings.Join([]string{prog, filename}, " ") escapedCommand := strings.Join([]string{prog, shellescape.Quote(filename)}, " ") fmt.Println(unescapedCommand) fmt.Println(escapedCommand) }
Output: /bin/ls myfile; rm -rf / /bin/ls 'myfile; rm -rf /'
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.