What Is Expected to Run Under OSH - oilshell/oil GitHub Wiki
Batch shell programs generally run under OSH unmodified. See Shell Programs That Run Under OSH.
Interactive scripts like .bashrc
often don't run without modifications. However, I do share my .bashrc
and oshrc
, so it can work. See the last section of How To Test OSH.
Related: Known Differences Between OSH and Other Shells
Common issues
BASH_VERSINFO
checks should be removed. We don't emulate a specific version of bash. Note that Feature Detection Is Better than Version Detection (if you want to write portable scripts)missing(2/2020: we stubbed these out)shopt
options likecheckwinsize
Sometimes Small Rewrites Are Necessary
OSH might not run every script unmodified. In general OSH is designed so you can make a small rewrite and the code will still run under bash and OSH. For example, some dynamic features of bash can usually be replaced with eval
, and it will run under both shells. (This is the "common subset principle", mentioned on Language Design Principles.)
Compatibility Options
TODO: Document these further.
shopt -s eval_unsafe_arith
-- for recursive evaluation of expression inside x in$(( x ))
, etc.shopt -s parse_dynamic_arith
-- for(( ${prefix}foo = bar ))
shopt -s compat_array
--${array}
is${array[0]}