brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: shellcheck finds quoting mistakes in a shell script before they run

Shell
~/tips/tip-shell-shellcheck-quoting

shellcheck backup.sh

Scans a shell script for common mistakes such as unquoted variables.

Unquoted variables are the bug I see most, and shellcheck spots them in a second.

shellcheck backup.sh
shellcheck -x -s bash backup.sh

shellcheck reports each problem with a code like SC2086 and a link to a page that explains the fix. -s bash sets the dialect when there is no shebang, and -x follows files loaded with source. Install it with apt install shellcheck. A line like # shellcheck disable=SC2086 silences one warning when you are sure.

Further reading: ShellCheck wiki: SC2086

More Shell tips zmv -n '(*).log' '$1.txt' zoxide query -ls project f=$(mktemp --suffix=.json) shopt globskipdots echo $EPOCHSECONDS All Shell tips (78) All topics

Link