Warning: Work in progress! Leave feedback on Zulip or Github if you'd like this doc to be updated.
This chapter in the Oils Reference describes global shell options for OSH and YSH.
Option in this group disallow problematic or confusing shell constructs. The resulting script will still run in another shell.
shopt --set strict:all # turn on all options
shopt -p strict:all # print their current state
Options in this group enable Oil features that are less likely to break existing shell scripts.
parse_at means that
@myarray is now the operation to splice
an array. This will break scripts that expect
@ to be literal, but you can
simply quote it like
'@literal' to fix the problem.
shopt --set ysh:upgrade # turn on all options
shopt -p ysh:upgrade # print their current state
Enable the full Oil language. This includes everything in the
shopt --set ysh:all # turn on all options
shopt -p ysh:all # print their current state
continue at the top level, and disallow empty args like
Failed tilde expansions cause hard errors (like zsh) rather than silently
strict_nameref is set, undefined references produce fatal errors:
declare -n ref
echo $ref # fatal error, not empty string
ref=x # fatal error instead of decaying to non-reference
References that don't contain variables also produce hard errors:
declare -n ref='not a var'
echo $ref # fatal
ref=x # fatal
For compatibility, Oil will parse some constructs it doesn't execute, like:
return 0 2>&1 # redirect on control flow
When this option is disabled, that statement is a syntax error.
Allow the r prefix for raw strings in command mode:
echo r'\' # a single backslash
Since shell strings are already raw, this means that Oil just ignores the r prefix.
If a process that's part of a pipeline exits with status 141 when this is option is on, it's turned into status 0, which avoids failure.
SIGPIPE errors occur in cases like 'yes | head', and generally aren't useful.
Normally, when no files match a glob, the glob itself is returned:
$ echo L *.py R # no Python files in this dir
L *.py R
With nullglob on, the glob expands to no arguments:
shopt -s nullglob
$ echo L *.py R
(This option is in GNU bash as well.)
Do globs return results that start with
-? It's on by default in
but off when Oil is enabled.
Turning it off prevents a command like
rm * from being confused by a file
$ touch -- myfile -rf
$ echo *
$ shopt -u dashglob
$ echo *