-
-
Notifications
You must be signed in to change notification settings - Fork 163
What Is Expected to Run Under OSH
andychu edited this page Jun 25, 2024
·
13 revisions
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
-
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)
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.)
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]}