NOTE: This document is a work in progress!
- Below is a list of topics, organized into [Sections]. - Features not yet implemented have an X prefix. - View it on the web at https://www.oilshell.org/TODO INTRO [Overview] overview [Usage] osh-usage oil-usage config startup line-editing COMMAND LANGUAGE [Commands] simple-command semicolon ; [Conditional] case if true false colon : bang ! and && or || dbracket [[ [Iteration] while until for for-expr (( [Control Flow] break continue return [Grouping] function block { subshell ( [Concurrency] pipe | X |& ampersand & X proc-sub [Redirects] redir-file > >> >| < <> X &> redir-desc >& <& here-doc << <<- <<< [Other] dparen (( time coproc ASSIGNING VARIABLES [Keywords] local readonly export unset shift X declare X typeset X let [Operators] assign str='xyz' X append str+='abc' [Compound Data] array array=(a b c) array[x]=b X assoc declare -A assoc=([a]=1 [b]=2) WORD LANGUAGE [Quotes] quotes 'abc' $'\n' "$var" [Substitutions] com-sub $(command) `command` var-sub ${var} arith-sub $((1 + 2)) $[1 + 2] tilde-sub ~/src X proc-sub diff <(sort L.txt) <(sort R.txt) [Special Vars] special-vars $? $# $PPID $IFS ... [Var Ops] op-test ${x:-default} X op-unary ${x%%suffix} etc. X op-str ${x/y/z} X op-slice ${a[@]:0:1} OTHER SHELL SUBLANGUAGES [Arithmetic] arith-intro Contexts where math is allowed num-literals 0xFF 0755 etc. math 1 + 2*3 arith-logical !a && b bitwise ~a ^ b arith-assign a *= 2 [Boolean] dbracket [[ $a == $b ]] [Patterns] glob *.py X extglob @(*.py|*.sh) regex [[ foo =~ [a-z]+ ]] [Brace Expand] braces {alice,bob}@example.com BUILTIN COMMANDS [I/O] read echo X readarray X mapfile X select [Run Code] source . eval [Set Options] set X shopt [Working Dir] cd pwd pushd popd dirs [Completion] complete X compgen X compopt [Shell Process] exec exit X logout umask X ulimit X trap X times [Child Process] jobs wait ampersand & X fg X bg X disown X [Word Lookup] command builtin X [Introspection] help hash type caller X [Interactive] alias unalias bind history fc X [External] test [ printf getopts kill X [Unsupported] enable SHELL OPTIONS [Parsing] [Execution] errors (nounset, errexit, pipefail, ...) globbing (noglob, failglob, ...) debugging (xtrace, verbose, ...) [OSH Options] strict sane
OSH is a shell.
Usage: osh [OPTION]... SCRIPT [ARG]... osh [OPTION]... -c COMMAND [ARG]... osh accepts POSIX sh flags, with the following differences: -n only validate the syntax. Also prints the AST. --show-ast print the AST in addition to executing. --ast-format what format the AST should be in
Usage: oil MAIN_NAME [ARG]... MAIN_NAME [ARG]... oil behaves like busybox. If it's invoked through a symlink, e.g. 'osh', then it behaves like that binary. Otherwise the binary name can be passed as the first argument, e.g.: oil osh -c 'echo hi'
The command language is specified by the POSIX shell grammar.
Simple commands are separated by words: ls / Redirects can also appear anywhere echo hi 1>&2
; -- separate statements
For conditionals.
OSH aims to have almost all of the builtins that bash does. Here they are, divided into sections.
These builtins take input and output. They are often used with redirects[1]. [1] help redirects
Usage: read -p Or maybe get rid of #END -- it can just go until the next # command. It's a little bit like the spec tests honestly. Can copy sh_specpy
source . eval
set X shopt
cd pwd pushd popd dirs
complete X compgen X compopt
exec exit X logout umask X ulimit X trap X times
jobs wait ampersand & X fg X bg X disown
Usage: help <topic> -- show help on a given topic help toc -- list help topics help osh-usage -- same as osh --help help oil-usage -- same as oil --help View on the web: http://www.oilshell.org/$VERSION/doc/osh-quick-ref.html
External: bash has builtins that replace these external commands, but OSH doesn't)
use /usr/bin/getopt
bash accepts job control syntax
Bash has this, but OSH won't implement it.