Lifegoal unlocked!
Ein Shellscript für eine Installationsroutine geschrieben, #shellcheck ausgeführt und auf Anhieb dort keine Fehler oder Notizen ausgelöst \o/
Lifegoal unlocked!
Ein Shellscript für eine Installationsroutine geschrieben, #shellcheck ausgeführt und auf Anhieb dort keine Fehler oder Notizen ausgelöst \o/
@inlovewithpda #bash is great, I've developed many a helping monster script. But bash also is a beast when it comes to getting it right. It's helpful to use a #Linter (like #shellcheck for example).
Even more important is to know when you should drop your bash script, consider it a prototype and reimplement it with a language that suits the problem better.
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.
Just a quick reminder: if you're writing #shell scripts, always use #shellcheck. It'll make your life so much easier! https://www.shellcheck.net/
#bash #linux #scripting #programming
@zhenech well, yes, I do have #shellcheck wired in a bunch of builds, just not for all packages I'm touching today, from multiple machines, not all of them having proper editors/hooks/confs deployed. That's why I'm enjoying #lintian as the last line of defense before wasting time.