Your periodic reminder that Shellcheck is awesome and should be used everywhere...
Your periodic reminder that Shellcheck is awesome and should be used everywhere...
Finally had a reason to figure out what shellcheck means with "prefer mapfile…" https://www.shellcheck.net/wiki/SC2207
Also, https://www.shellcheck.net/wiki/SC2068, quote array expansion.
Yes, I need to read a file to an array, each line may contain spaces, and I need to pass each line as an argument to another thing.
mapfile -t lines < inputfile
dostuff "${lines[@]}"
actually does what I need, without a BUNCH of headaches.
It only took me a bit more than a quarter of a century before I got here 🙂
Lifegoal unlocked!
Ein Shellscript für eine Installationsroutine geschrieben, #shellcheck ausgeführt und auf Anhieb dort keine Fehler oder Notizen ausgelöst \o/
I just learned ShellCheck is written in Haskell and I can't stop laughing.
Not because I don't like Haskell — quite the opposite, it's high on the list of languages I hope I can get real day-to-day working experience with — but because it's so rare to get a popular project and find "the easiest way to install is using Cabal" in the readme.
Ran #shellcheck on my thesis's #Bash part and it detected like 6 errors. Some were false positives, but one was an actual problem. I was saving the passed arguments and needed to save them and temporarily remove all of them so that a sourced script doesn't exec them and it turns out that arrays in Bash are even more cursed than I thought.
I don't think I'm ever going to write shell scripts without shellcheck. Honestly it should be installed by default on every non-minimal #Linux distro.
edit: To clarify, the false positives were also things to be mindful of, specifically sourcing unknown command outputs, but it was search paths from guix, so it was fine in this very specific case.