Skip to content

Cross platform Go implementation of a POSIX shell

License

Notifications You must be signed in to change notification settings

tsukinoko-kun/ohmygosh

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Oh My Gosh! 😱

Install

go get -u github.com/tsukinoko-kun/ohmygosh

Usage

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)
	}
}

Features

  • 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)