by initplus · 5y ago · 0 comments
rm -rf /$MYVAR
If you don't set $MYVAR and don't set bash to error on unset variables you are in for trouble.You can also prevent this by never using $VAR, and instead always using ${VAR:?} to exit with error if VAR is unset (or use one of the other options to provide a default).
From that day onward I always make sure the first line of my bash scripts contains at least "set -e".