|
|
|
|
|
by vog
3383 days ago
|
|
> All scripts should be run with "-eu". More specifically, every shell script should have "set -eu" at its second line, directly after the sh'bang line: #!...
set -eu
For debugging or logging purposes, sometimes adding -v and/or -x comes handy: #!...
set -euvx
|
|
Do you have a strong reason to prefer "set" over shebang flags? I have a slight preference for shebang flags so I can deliberately override them from the command line (but it's not a hill I'd die on):
EDIT: Google's shell style guide has "Executables must start with #!/bin/bash and a minimum number of flags. Use set to set shell options so that calling your script as bash <script_name> does not break its functionality."https://google.github.io/styleguide/shell.xml?showone=Which_...