Hacker News new | ask | show | jobs
by chubot 558 days ago
If you have thousands of lines of bash, don't like maintaining it, but don't necessarily want to rewrite the whole thing at once, that's what https://www.oilshell.org/ is for!

See my comment here, with some details: https://news.ycombinator.com/item?id=42354095

(I created the project and the wiki page. Right now the best bet is to join https://oilshell.zulipchat.com/ if it interests you. People who want to test it out should be comfortable with compiling source tarballs, which is generally trivial because shells have almost no dependencies.)

The first step is:

    shopt --set strict:all  # at the top of the file
Or to run under bash

    shopt -s strict:all 2>/dev/null || true
And then run with "osh myscript.bash"

OSH should run your script exactly the same as bash, but with better error messages, and precise source locations.

And you will get some strictness errors, which can help catch coding bugs. It's a little like ShellCheck, except it can detect things at runtime, whereas ShellCheck can't.