by fiddlerwoaroof · 5y ago · 0 comments
I've found that the best way to introduce someone to ShellCheck is to run it on their script, right in front of them, with most saying something like "How did I not know about this?". Linters are great!
I consider it an example of the general trend against learning domain-specific languages.
My boss and coworker just spent the weekend on seven million files on my script.
find . -type f -print0 | xargs -0 (cygwin) sed 's/\ff//'
They think me a genius. This is nothing.
There are a few simple rules that, once you learn them, eliminate those kinds of problems. The main one is always use double-quotes around variable dereferences. The second is learning a few patterns, like find ... -print0 | xargs -0 ...
But even after you've learned those simple rules, shellcheck is still useful. It will find fewer problems, but that's a good thing, that means you learned something :-).