TL;DR: e aborts the whole script on a non-zero error. u aborts when using an undefined variable. -o pipefail aborts a piped compound command when one of the piped commands fail.
Any other way lies madness. Or erasing the whole filesystem apparently!
Yes! But -u is for undefined variables. It won’t stop a defined variable with an empty value. E.g foo=“”.
Also ? and :? have the advantage of telling you right then and there where the variable use is that it must be defined or not empty… having to trek back to (likely) the top of the script to check is easily forgotten.
Most people don’t know that an appeal to a higher court is an exercise in “did the lower court follow procedure” rather than I want to re-litigate the case.
Always do rm -rf “${var:?}/” so that the script aborts if the variable is empty. Or better yet rm -rf “./${var:?}/”.
Edited to add quotes. Always quote a path: it might have spaces in it, without quotes that will become multiple paths! Which would also have avoided the particular bug in question.