[GTALUG] Man deletes his entire company
William Park
opengeometry at yahoo.ca
Fri Apr 15 15:45:58 EDT 2016
"set -u" won't help in case of foo= bar= rm -rf $foo/$bar
On Friday, April 15, 2016 1:46 PM, D. Hugh Redelmeier <hugh at mimosa.com> wrote:
| From: Scott Allen <mlxxxp at gmail.com>
| The script actually contained
| rm -rf {foo}/{bar}
|
| The error caused foo and bar to be null so the result was
| rm -rf /
I don't know what was processing the commands. If it was a normal
shell, it ought to have been
rm -rf ${foo}/${bar}
This is EXACTLY why I start all my shell scripts with
set -eu
The e means stop on an unexpected non-zero return code.
The u means that referenceing an unset variable is an error.
---
Talk Mailing List
talk at gtalug.org
https://gtalug.org/mailman/listinfo/talk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://gtalug.org/pipermail/talk/attachments/20160415/4f3ee42f/attachment.html>
More information about the talk
mailing list