github.com/sgreben/0sh

very simple (sub-POSIX) shell for scripting. single binary, no dependencies. osx, linux, windows. #golang


Keywords
posix, shell, sub, tiny
License
MIT
Install
go get github.com/sgreben/0sh

Documentation

0sh

Very simple (sub-POSIX) shell for scripting.

Contents

Features

  • $ENV variables (read usage only, no assignment)
  • double-quoted strings (expansion, escapes) and single-quoted strings (neither)
  • built-ins: cd and exit
  • no branching of any kind (conditionals or loops)
  • no pipes (NOTE: this might change)
  • -e (errexit) and -u (noundef) enabled by default

Example

#!/usr/bin/env 0sh
echo "$ABC" '$ABC' # a comment
exit 1

Get it

Using go get

go get -u github.com/sgreben/0sh

Pre-built binary

Or download a binary from the releases page, or from the shell:

# Linux
curl -L https://github.com/sgreben/0sh/releases/download/0.0.2/0sh_0.0.2_linux_x86_64.tar.gz | tar xz

# OS X
curl -L https://github.com/sgreben/0sh/releases/download/0.0.2/0sh_0.0.2_osx_x86_64.tar.gz | tar xz

# Windows
curl -LO https://github.com/sgreben/0sh/releases/download/0.0.2/0sh_0.0.2_windows_x86_64.zip
unzip 0sh_0.0.2_windows_x86_64.zip

Use it

0sh [OPTIONS]
Usage of 0sh:
  -c string
    	run only the given COMMAND
  -e	exit on error (default true)
  -n	dry-run
  -u	error on undefined (default true)
  -v	verbose
  -version
    	print version and exit