Skip to content

Latest commit

 

History

History

scipting_best_practices

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 

bash: improve your command line & script productivity

scipting best practices

fail on errors including undefined variables!

#!/bin/bash -eu

set -e
set -u

# temporarily accept failure with:
set +e
# or:
./bad-program || true

log tracing to a file (other than stderr)

exec 42>log.xtrace
BASH_XTRACEFD=42
set -x

log to a file (from within a script)

exec &> >(tee script.log)