This commit is contained in:
2013-07-09 06:59:42 -04:00
parent c3fe169bdd
commit e10acfbd05

View File

@@ -156,6 +156,19 @@ function cmdarg_parse
fi fi
} }
function cmdarg_traceback
{
# This code lifted from http://blog.yjl.im/2012/01/printing-out-call-stack-in-bash.html
local i=0
local FRAMES=${#BASH_LINENO[@]}
# FRAMES-2 skips main, the last one in arrays
for ((i=FRAMES-2; i>=0; i--)); do
echo ' File' \"${BASH_SOURCE[i+1]}\", line ${BASH_LINENO[i]}, in ${FUNCNAME[i+1]}
# Grab the source code of the line
sed -n "${BASH_LINENO[i]}{s/^/ /;p}" "${BASH_SOURCE[i+1]}"
done
}
if [[ "${_DEFINED_CMDARG}" == "" ]]; then if [[ "${_DEFINED_CMDARG}" == "" ]]; then
export _DEFINED_CMDARG=0 export _DEFINED_CMDARG=0
# Holds the final map of configuration options # Holds the final map of configuration options