I have all the programming ability of a wet dog. I am aware of that shortcoming though, and I try to keep things on hand that either (a) make me look like I know what I’m doing, or (b) will discreetly tell me when I don’t know what I’m doing, so as not to embarrass me in front of the hired help.
Hence my affinity for things like perltidy, tidyhtml and even txt2regex. 😛
Even if I don’t keep shellcheck installed, I’m keeping a bookmark to its online version, because it definitely lets me know when I’ve done something stupid.
That’s my goal in life: to stop doing stupid things. And shellcheck has already told me that I’m doing one or two in that script.
Things I like: the colored output, the arrow-pointers to tell me exactly where I made my mistake, and the error codes that I can use to get more information online. And by extension, the ability to exclude specific errors, if I know they are in there but don’t want to be teased about them.
Things I would suggest: It’s a little difficult to take some errors out of context, particularly if they break over a line or if something earlier in the script is related. As things stand, shellcheck only seems to point out lines that have errors, regardless of where they stand in relation to lines above or below.
As a side note, it seems like this is an obvious candidate for some kind of two-pane output display, with the text of the shell on one side, and an arrow-key-driven selector that bounces between errors, with the error code and explanation changing in a second panel, as the highlight moves. Imagine how some file managers show file information as you scroll through the contents of a directory, and that’s what I have in my mind.
But what do I know. Maybe I’m just dreaming, and what shellcheck has is good, but that’s what I’d look for in an updated version.
shellcheck in its local form is a bit of a heavyweight, when it comes time to build it. I usually have rotten luck with Haskell-based software, but this time the AUR package worked fine. The home page warns that you’ll need about 1Gb just to build shellcheck, and I think that’s where my machine peaked while it was building. So don’t put this together on your leftover 300Mhz K6 with 128Mb. You will regret it. 😦
Lol, used it last week from the online service. It’s not really straight forward, like I sweated a lot to discover a missing fi, but I’ve learned a new thing from that tool: when you work with subshell you should use tempfiles instead of variables. I didn’t know that before.
I didn’t know that either. Which makes me think, maybe I should find out where shellcheck’s points of etiquette come from. I assume there must be manuals or guides for best practices for shell scripts. Or does the world just wait for Stallman to burp out another nugget of wisdom? 🙂
My opinion is that somewhere exist guides that treats the posix shell as a programming language and not as a turing-complete userbase extension language, like the things you learn on the paper on Rc by Tom Duff ( http://plan9.bell-labs.com/sys/doc/rc.html ). Problem is, I don’t know where 😦
And probably the only best practice in shell script is “If you can’t make it in 500 SLOC, write it in C because you’ve wasted enough time”. 😉