"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 <[email protected]> 
wrote:
 
 

 | From: Scott Allen <[email protected]>

| 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
[email protected]
https://gtalug.org/mailman/listinfo/talk


 
  
---
Talk Mailing List
[email protected]
https://gtalug.org/mailman/listinfo/talk

Reply via email to