3 ms·
Here's Why You Should Quote Your Variables in Bash
- LinuxBender 8y agoThis is one of the many things that would be called out if you run your shell script through shellcheck [1] source [2] [1] - https://www.shellcheck.net/ https://www.shellcheck.net/ [2] - https://github.com/koalaman/shellcheck https://github.com/koalaman/shellcheck Shellcheck is also in several yum repos such as EPEL and in homebrew for Mac. You can add a comment in your script to exclude / ignore specific warnings. Examples are in the man page.
- nickjj 8y agoYep, I use Shellcheck in VSCode with https://github.com/timonwong/vscode-shellcheck https://github.com/timonwong/vscode-shellcheck. But it won't save you if you're on a server executing raw commands so it's still good to know about the concerns of omitting quotes.