That's a usefull one to know for tracing through the whole script, thanks!
However, I was looking for something whereby I can selectively control what get printed out. Also, I don't actually want to run some of the commands in the script, just print out what 'would' have run. The 'set -x' still actually proceeds and executes the various script statements.
I've so far got a slightly better version...
debugmessage() { if [ $debugOn ] ; then
echo "$@"
else
$@
fi
}
Then, I can have the following command in the script...
debugmessage rm -rf $dir
and if debug is on, it will not actually run the 'rm' command, just print it out.
However, the above gives me an error... "line 34: debug:: command not found", which relates to the line after the 'else' with "$@" on it
Almost there but possibly a much better way?
Ta.
-david