4 ms·
> Unset variables. If DIR is unset, rm -rf $DIR/ becomes rm -rf /. Using set -u can make bash error when encountering unset variable. sweet mercy :O Someone c
by upghost 1y ago
> Unset variables. If DIR is unset, rm -rf $DIR/ becomes rm -rf /. Using set -u can make bash error when encountering unset variable.
sweet mercy :O
Someone call the Inquisition
- AnimalMuppet 1y agoInstead, say rm -rf $DIR That is, skip the trailing slash. Then if $DIR is not set, it becomes an invalid command, because no file names were supplied.
- Terr_ 1y agoBetter to make the requirement explicit, instead of relying on the argument-parsing details of rm or some other command: # Default message $ rm -rf "${DIR:?}" bash: DIR: parameter null or not set # Custom message $ rm -rf "${DIR:?It is not set OMG}" bash: DIR: It is not set OMG
- mdaniel 1y agoThis was a very famous Steam bug