Permalink
Browse files

Update the quick ref for 0.4.0.

- exit is now control flow
- more special vars
- more sane-* options
- more quick ref topics
- document the % prefix in Oil.
  • Loading branch information...
Andy Chu
Andy Chu committed Jan 25, 2018
1 parent 5be68c6 commit 12c8a6bfe96dfe56ddc338699cf9c6f82a5b4584
Showing with 67 additions and 16 deletions.
  1. +43 −0 doc/osh-quick-ref-pages.txt
  2. +24 −16 doc/osh-quick-ref-toc.txt
@@ -96,6 +96,49 @@ first argument, e.g.:
### <prompt> Customizing the Prompt String
#### <Lexing> Lexing
#### <Oil Lexing> Oil Lexing
### <single-command> The % Prefix Starts a Single Command Over Multiple Lines
This special lexer mode has several use cases:
Long command lines without trailing \
% chromium-browser
--no-proxy-server
# comments allowed
--incognito
Long pipelines or and-or chains without trailing \
% find .
# exclude tests
| grep -v '_test.py'
| xargs wc -l
| sort -n
% ls /
&& ls /bin
&& ls /lib
|| error "oops"
Using {} for brace expansion, rather than the start of a block:
% echo {alice,bob}@example.com
%
echo next # blank line or bare % required to end the command
NOTE: This should be valid without % :
ls *.[ch]
Using Oil syntax at an OSH shell prompt:
$ echo hi >&2 # POSIX sh syntax
$ % echo hi > !2 # Oil syntax
##### <COMMAND-LANGUAGE> Command Language
The command language is specified by the POSIX shell grammar.
View
@@ -10,17 +10,17 @@ INTRO
[Usage] osh-usage oil-usage config startup line-editing
prompt
[Lexing] comments # line-continuation \
[Oil Lexing] single-line $ docstring?
[Oil Lexing] single-command % docstring?
COMMAND LANGUAGE
[Commands] simple-command semicolon ;
[Conditional] case if true false colon :
bang ! and && or || dbracket [[
[Iteration] while until for for-expr-sh ((
[Control Flow] break continue return
[Control Flow] break continue return exit
[Grouping] function block { subshell (
[Concurrency] pipe | X |&
ampersand & X proc-sub
ampersand &
[Redirects] redir-file > >> >| < <> X &>
redir-desc >& <&
here-doc << <<- <<<
@@ -59,11 +59,11 @@ WORD LANGUAGE
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 ...
proc-sub diff <(sort L.txt) <(sort R.txt)
[Special Vars] special-vars $@ $* $# $? $- $$ $!
[Var Ops] op-test ${x:-default}
op-unary ${x%%suffix} etc.
op-str ${x/y/z}
op-str ${x//y/z}
op-slice ${a[@]:0:1}
X [Oil Quotes] c-string c'1\t2\n' c"1\t$two\n"
safe-subst h"<p>$[name]</p>"
@@ -75,7 +75,13 @@ OTHER SHELL SUBLANGUAGES
arith-logical !a && b
bitwise ~a ^ b
arith-assign a *= 2
[Boolean] dbracket [[ $a == $b ]]
[Boolean] dbracket [[ vs. the test builtin
bool-expr [[ ! $x && $y || $z ]]
test ! $x -a $y -o $z
bool-infix [[ $a -nt $b ]] [[ $x == $y ]]
bool-path [[ -d /etc ]]
bool-str [[ -z '' ]]
bool-other [[ -o errexit ]]
[Patterns] glob *.py
X extglob @(*.py|*.sh)
regex [[ foo =~ [a-z]+ ]]
@@ -84,12 +90,12 @@ OTHER SHELL SUBLANGUAGES
BUILTIN COMMANDS
[I/O] read echo
X readarray X mapfile
[Run Code] source . eval
[Run Code] source . eval trap
[Set Options] set 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
[Shell Process] exec X logout
umask X ulimit X times
[Child Process] jobs wait ampersand &
X fg X bg X disown
[External] test [ X printf getopts X kill
@@ -99,7 +105,7 @@ X [Interactive] alias unalias bind history fc
X [Unsupported] enable
OIL BUILTINS
[I/O] write readline
[I/O] write readline sh-builtin
[External] dirname basename env ?
SHELL OPTIONS
@@ -108,20 +114,23 @@ SHELL OPTIONS
[Debugging] xtrace X verbose X extdebug
[Other] X noclobber
[Parsing] TODO
[OSH Strict] STRICT strict-control-flow X strict-arith
[OSH Strict] STRICT strict-array strict-control-flow
strict-errexit X strict-arith
[OSH Sane] SANE X sane-no-word-split X sane-glob
X sane-echo X sane-read X sane-eval X sane-trap
ENVIRONMENT VARIABLES
X [Prompts] PS1 PS2
X [select] PS3
[xtrace] PS4
[Shell Options] X SHELLOPTS X BASHOPTS
[Shell Options] SHELLOPTS X BASHOPTS
[Other] HOME PATH IFS
SPECIAL VARIABLES
X [Platform] HOSTNAME OSTYPE BASH_VERSION @BASH_VERSINFO
X [Call Stack] @BASH_SOURCE @FUNCNAME @BASH_LINENO
@BASH_ARGV @BASH_ARGC LINENO
@BASH_ARGV @BASH_ARGC
[Tracing] LINENO SOURCE_NAME
[Process State] X BASHPID X PPID UID EUID
X [Process Stack] BASH_SUBSHELL SHLVL
X [Shell State] BASH_CMDS @DIRSTACK
@@ -130,7 +139,6 @@ X [Shell State] BASH_CMDS @DIRSTACK
[read] REPLY IFS
[Functions] X RANDOM X SECONDS
[Other] BASH_REMATCH @PIPESTATUS
[Oil] SOURCE_NAME
PLUGINS AND HOOKS
X [Signals] SIGINT SIGABRT SIGTODO
@@ -152,5 +160,5 @@ OIL LIBRARIES
X [getopts] ?
X [Testing] ?
X [Data Formats] json csv tsv2
X [Hash Functions]

0 comments on commit 12c8a6b

Please sign in to comment.