3 ms·
Instead, 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.
by AnimalMuppet 1y ago
Instead, 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