Skip to content

Commit

Permalink
Merge pull request #185 from tegonal/improve/error-message-of-checkAr…
Browse files Browse the repository at this point in the history
…gIsFunction

improve the error message with colours and fix text about ref name
  • Loading branch information
robstoll authored Apr 11, 2024
2 parents f042dc8 + 846b95c commit 69c2a9f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/utility/checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -208,12 +208,12 @@ function checkArgIsFunction() {

if ! declare -F "$name" >/dev/null; then
local declareP
declareP=$(declare -p "$name" || echo "failure, is not a variable")
declareP=$(declare -p "$name" || printf "failure: \033[0;36m%s\033[0m is not a variable\n" "$name")
local funcName=${FUNCNAME[1]}
if [[ $funcName == "exitIfArgIsNotFunction" ]]; then
funcName=${FUNCNAME[2]}
fi
traceAndReturnDying "the %s argument to %s needs to be a function/command, %s isn't one\nMaybe it is a variable storing the name of a function?\nFollowing the output of: declare -p %s\n%s" \
traceAndReturnDying "the %s argument to %s needs to be a function/command, \033[0;36m%s\033[0m isn't one\nMaybe it is the name of a variable storing the name of a function?\nFollowing the output of: declare -p %s\n%s" \
"$argNumberOrName" "$funcName" "$name" "$name" "$declareP"
fi
}
Expand Down

0 comments on commit 69c2a9f

Please sign in to comment.