Add a nicer trace prompt for $PS4

Since we are standardizing on bash for shell scripts, we may as well
tell it to use a trace prompt that is vastly more useful for debugging.

This patchset changes $PS4 to prepend the script name and line number to
every line output in a debug trace.

Change-Id: I4ec5c0253295724a9580f86fd30082acd89d155d
This commit is contained in:
Victor Lowther 2014-05-16 11:56:48 -05:00
parent eb6dbe29d8
commit 95302bc32f
1 changed files with 7 additions and 0 deletions

View File

@ -3,6 +3,13 @@
# Demo script for Tripleo - the dev/test story.
# This can be run for CI purposes, by passing --trash-my-machine to it.
# Without that parameter, the script is a no-op.
# Set PS4 as early as possible if it is still at the default, so that
# we have a useful trace output for everything when running devtest.sh
# with bash -x ./devtest.sh
if [ "$PS4" = "+ " ]; then
export PS4='${BASH_SOURCE}@${LINENO}: '
fi
set -eu
set -o pipefail
SCRIPT_NAME=$(basename $0)