Hacker News new | ask | show | jobs
by kenny_r 3382 days ago
ShellCheck warned me of a very similar issue in a script of mine recently. In that script I ran the following:

  rm -rf "${FOO}/"
ShellCheck helpfully warned me that that could have disastrous consequences when FOO is unset, instead it advised me to use this:

  rm -rf "${FOO:?}/"
I'd also like to point out that ShellCheck is in the AUR for users of Arch Linux[0], and that there's a handy plugin which I use for the Atom editor[1].

[0] https://aur.archlinux.org/packages/shellcheck-git/

[1] https://atom.io/packages/linter-shellcheck

2 comments

There is also a plugin for sublime text [0] It doesn't take long to internalize the corrections. It's well worth using a linter if one is available.

[0] https://github.com/SublimeLinter/SublimeLinter-shellcheck

shellcheck is also in the community repo: https://www.archlinux.org/packages/community/x86_64/shellche...