5 ms·
I highly recommend ShellCheck[0] if you're writing any bash. With the warnings and stylistic advice it provides, I feel like I can actually be confident that my
by mambodog 9y ago
I highly recommend ShellCheck[0] if you're writing any bash. With the warnings and stylistic advice it provides, I feel like I can actually be confident that my scripts are doing what I think they're doing.
[0]: https://github.com/koalaman/shellcheck https://github.com/koalaman/shellcheck
- helb 9y agoI second this, it's a great tool. However, don't let it give you a false sense of security. Shellcheck probably won't say anything about the "biting" parts from the article – because they are valid, just behaving a bit different than the user expects… That goes for any linter or static analyser i guess.
- bjackman 9y agoDunno about this particular case but I'd say linters are exactly for finding things that are valid but behave differently than the user expects. E.g. "if (x = 1)" is valid C but i'd be pretty unimpressed if a linter didn't flag it up!
- jwilk 9y agoYup, shellcheck 0.4.4 says this this code is fine.
- hultner 9y agoThanks! That's a great tip. I've been writing a large amount of shell scripts (mainly sh not so much bash) and already made some improvements thanks to this!
- cavanasm 9y agoI recently started having to do a lot of shell work, and shellcheck has helped immensely. It was unfortunate that there was no precompiled version of GHC for my OSX version on homebrew though, so it took 5 hours to build GHC. I ended up turning off all the power save and auto sleep features on my laptop to make sure it kept going.
- FooBarWidget 9y agoYou know you can just install the binary from Homebrew right?
- amorphid 9y agoThanks for the tip. Will check it out.
- pmarreck 9y agoThat's awesome and I've added it to my toolchain. But I can't help but think that this is more a sign of how wart-filled Bash really is. Perhaps it's time for a new shell language that is less arcane, with fewer gotchas and simply less bug potential?
- paulddraper 9y agoWell there's dash, fsh, zsh, etc. Unless you mean something entirely different than POSIX shell family, e.g. Powershell, Python, Ruby, or JS.