go get -u github.com/tsukinoko-kun/ohmygosh
package main
import (
"fmt"
"os"
"github.com/tsukinoko-kun/ohmygosh"
)
func main() {
if err := ohmygosh.Execute(`echo "hello $(whoami)" | cat`); err != nil {
fmt.Println(err)
os.Exit(1)
}
}
- Execute basic shell commands (built-in)
- cd
- exit
- echo
- cat
- export
- unset
- whoami
- pwd
- which
- sudo
- unix
- windows
- yes
- true
- false
- sleep
- seq
- parallel
- type
- Execute programs from PATH or with explicit path
- Execute shell scripts
- Shell functions
- Shell aliases
-
command1 | command2
(pipe) -
command1 & command2
(parallel) -
command1 && command2
(if success) -
command1 || command2
(if failure) -
command1 ; command2
(sequential) -
command1 > file
(redirect stdout) -
command1 < file
(redirect stdin) -
command1 2> file
(redirect stderr) -
command1 2>&1
(redirect stderr to stdout) -
command1 1>&2
(redirect stdout to stderr) -
command1 &> file
(redirect stdout and stderr) -
command1 |& command2
(pipe stdout and stderr) -
command1 <<< "input"
(here string) -
command1 << EOF
(here document)