3 ms·
Since no one has said it yet, please always use https://www.shellcheck.net/ https://www.shellcheck.net/ on your scripts, you don't want to be That Guy https://g
by unhammer 4y ago
Since no one has said it yet, please always use https://www.shellcheck.net/ https://www.shellcheck.net/ on your scripts, you don't want to be That Guy https://github.com/ValveSoftware/steam-for-linux/issues/3671 https://github.com/ValveSoftware/steam-for-linux/issues/3671
- rob_c 4y agoOh I do love reading those... Shame that shell scripting is still treated as mysterious command line voodoo, even Microsoft has Powershell now showing how powerful the concept is that even they couldn't avoid it entirely
- tyingq 4y agoAh, wow. I like that they ported the accidental behavior deliberately into Windows: Warning: The uninstallation process deletes the folder Steam was installed to to ensure it is fully uninstalled. If you accidentally installed Steam to a folder containing other data, for example C:\Program Files (x86)\ instead of C:\Program Files (x86)\Steam\..."
- doliveira 4y agoI'm probably being too judgemental, but I don't get how people are so nonchalant about mutability and potentially destructive commands. Even in a Github Gist I'm scared enough to set -euo pipefail, put half a dozen checks before removing a folder...
- synergy20 4y agoshellharden is also great, that semi-automate the process to conform with shellcheck
- bravetraveler 4y agoGeneral recommendation specifically for the Valve-like case: set -o nounset You can check variables as many ways you want, just do this too - safety net in case there's an eventual gap
- j1elo 4y agoAnd use the so-called "Bash unofficial strict mode", as described elsewhere. I prefer this summary of it, because the original includes stuff like changing IFS (the fields separators) which I agree with the Gist author to not include, because it is a Bad Idea to blindly suggest it universally. EDIT: This gist: https://gist.github.com/robin-a-meade/58d60124b88b60816e8349d1e3938615 https://gist.github.com/robin-a-meade/58d60124b88b60816e8349...
- Spivak 4y agoYou should also probably add either nullglob or failglob depending on your use case. I would also add dotglob because it’s rarer for me to want only non-hidden files than it is for me to want all files.