If you don't mind using python, the sh package [0] can really get you a bash-style repl (dinamically) typed.

.. [0]: http://amoffat.github.io/sh/

Yes, in my mind this is the way to go (the other alternative, probably unviable, being scsh https://github.com/scheme/scsh). I recently made a decision not to write any bash scripts that include a conditional or loop; for all those use cases python+sh is the way to go. The reason: http://mywiki.wooledge.org/BashPitfalls

I can't think of any environment where python would not be available. You can even ship sh.py as a single-file dependency along with your script, so `import cp from sh` will work as expected.