Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cmd ¶
Cmd is the base of the POSIX commands.
func Alias ¶
Alias is the alias wrapper for the POSIX command.
see: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/alias.html
Example ¶
package main import ( "fmt" "github.com/k-kinzal/aliases/pkg/posix" ) func main() { cmd := posix.Alias("foo", "echo 'Hello World'") fmt.Println(cmd) }
Output: alias foo='echo \'Hello World\''
func Command ¶
Command creates a new posix.Cmd.
Example ¶
package main import ( "os" "github.com/k-kinzal/aliases/pkg/posix" ) func main() { cmd := posix.Command("echo", "1") cmd.Stdout = os.Stdout if err := cmd.Run(); err != nil { panic(err) } }
Output: 1
func Export ¶
Export is the export wrapper for the POSIX command.
http://pubs.opengroup.org/onlinepubs/007904975/utilities/export.html
Example ¶
package main import ( "fmt" "github.com/k-kinzal/aliases/pkg/posix" ) func main() { cmd := posix.Export("FOO", "{\"foo\": 1}") fmt.Println(cmd) }
Output: export FOO="{\"foo\": 1}"
func PathExport ¶
PathExport returns the wrapper command `export PATH = ...`.
Example ¶
package main import ( "fmt" "github.com/k-kinzal/aliases/pkg/posix" ) func main() { cmd := posix.PathExport("/bin:/sbin") fmt.Println(cmd) }
Output: export PATH="/bin:/sbin:$PATH"
type ShellScript ¶ added in v0.3.0
type ShellScript Cmd
func Shell ¶
func Shell(commandString string) *ShellScript
Shell runs the POSIX command as a shell
http://pubs.opengroup.org/onlinepubs/009695399/utilities/sh.html TODO: Implement other options if there is a use case
Example ¶
package main import ( "os" "github.com/k-kinzal/aliases/pkg/posix" ) func main() { cmd := posix.Shell("echo $FOO") cmd.Stdout = os.Stdout cmd.Env = append(cmd.Env, "FOO=1") if err := cmd.Run(); err != nil { panic(err) } }
Output: 1
func (*ShellScript) String ¶ added in v0.3.0
func (shell *ShellScript) String() string
String returns body of shell script.
Example ¶
package main import ( "fmt" "github.com/k-kinzal/aliases/pkg/posix" ) func main() { cmd := posix.Shell("echo $FOO") fmt.Println(cmd) }
Output: echo $FOO
Click to show internal directories.
Click to hide internal directories.