Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

If your bash script is not trivial, and target machines have python, it's probably better to use sh:

https://amoffat.github.io/sh/



Love amoffat's sh. love.

Love it so much I wrote similarly styled libraries for both

- go: https://github.com/polydawn/gosh - java: https://github.com/polydawn/josh

I particularly like the golang one, because it results in smallish (~1mb) files that can crash land on any linux with no other bootstrap at all... which while troubling for replacing your entire library of shell scripts, is great for bootstrapping. (For replacing your entire library of shell scripts, I just use it with `go run` after my bootstrap has installed the go toolchain.)


First time I've seen this and it looks amazing. Poorly named perhaps, though it is certainly a nice option to be aware of! Thank you for sharing.

One question - In this py-sh system are there error control options like what bash provides? e.g.:

    set -o errexit
    set -o pipefail
    set -o nounset


These options are set by default - non zero exit code or unknown variable will raise an exception. You can catch it if you don't want to exit.


Similar ruby library. not as extensive since ruby has more shell-like features built in http://ruby-doc.org/stdlib-2.2.1/libdoc/shell/rdoc/Shell.htm...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: