Documentation
¶
Overview ¶
Package shell provides safe escaping of command line tokens
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Escape ¶
Example (Basic) ¶
package main
import (
"fmt"
"github.com/taskcluster/shell"
)
func out(args ...string) {
fmt.Println(shell.Escape(args...))
}
func main() {
out(`echo`, `hello!`, `how are you doing $USER`, `"double"`, `'single'`)
out(`'''`)
out(`'>''`)
out(`curl`, `-v`, `-H`, `Location;`, `-H`, `User-Agent: dave#10`, `http://www.daveeddy.com/?name=dave&age=24`)
out(`echo`, `hello\\nworld`)
out(`echo`, `hello:world`)
out(`echo`, `--hello=world`)
out(`echo`, `hello\\tworld`)
out(`echo`, `\thello\nworld'`)
out(`echo`, `hello world`)
out(`echo`, `hello`, `world`)
out(`echo`, "hello\\\\'", "'\\\\'world")
out(`echo`, "hello", "world\\")
out(`abc`, ``, `def`)
}
Output: echo 'hello!' 'how are you doing $USER' '"double"' \'single\' \'\'\' \''>'\'\' curl -v -H 'Location;' -H 'User-Agent: dave#10' 'http://www.daveeddy.com/?name=dave&age=24' echo 'hello\\nworld' echo hello:world echo --hello=world echo 'hello\\tworld' echo '\thello\nworld'\' echo 'hello world' echo hello world echo 'hello\\'\' \''\\'\''world' echo hello 'world\' abc '' def
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.