Skip to content

Latest commit

 

History

History
36 lines (29 loc) · 692 Bytes

debug.md

File metadata and controls

36 lines (29 loc) · 692 Bytes

bash debug via adding trace info with traps

trap 'echo "line ${LINENO}: ANSWER: $ANSWER"' DEBUG
trap 'echo "$BASH_COMMAND" failed with error code $?' ERR

bash debug file

# set -o xtrace
bash -x /opt/mapr/installer/docker/mapr-setup.sh

bash -u /opt/mapr/installer/docker/mapr-setup.sh

bash debug only code block

set -x 
# commands to debug
set +x

check syntax without running

bash -n myscript.sh

advanced syntax check

sudo apt install shellcheck
shellcheck myscript.sh

see also

how to catch/send signals from/to process