shell programming - testing

created onJanuary 18, 2022

shellcheck

Check shell scripts with ‘shellcheck’

Test shell scripts with the ‘-x’ switch:

#!/bin/bash -x

This will print the lines of the scripts that are executed, the value of the variables that are evaluated and the output of the expressions. If a shell script is executed with the ‘-x’ switch, all shell scripts that are executed within this script are executed with ‘-x’.

PS4 for debugging scripts

export PS4='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
export PS4='${LINENO} +'