Skip to content

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

Common issues

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]}

Related

Clone this wiki locally