Browse Source

debug_bash_helper: Use eval as busybox systems have problems

In _debug_bash_helper use eval as we are seeing issues with busybox
systems having issues with array access. Even though they aren't
actually running the code they appear to be parsing it and failing.

Also older versions of busybox have a bug with eval and double quotes,
so make sure to use single quotes when using eval.

Resolves: #2579
pull/2583/head
John L. Villalovos 5 years ago
parent
commit
adce8f52e8
  1. 16
      acme.sh

16
acme.sh

@ -268,31 +268,31 @@ _usage() {
__debug_bash_helper() { __debug_bash_helper() {
# At this point only do for --debug 3 # At this point only do for --debug 3
if [ "${DEBUG:-$DEBUG_LEVEL_NONE}" -lt "$DEBUG_LEVEL_3" ]; then if [ "${DEBUG:-$DEBUG_LEVEL_NONE}" -lt "$DEBUG_LEVEL_3" ]; then
echo ""
return return
fi fi
# Return extra debug info when running with bash, otherwise return empty # Return extra debug info when running with bash, otherwise return empty
# string. # string.
if [ -z "${BASH_VERSION}" ]; then if [ -z "${BASH_VERSION}" ]; then
echo ""
return return
fi fi
# We are a bash shell at this point, return the filename, function name, and # We are a bash shell at this point, return the filename, function name, and
# line number as a string # line number as a string
_dbh_saveIFS=$IFS _dbh_saveIFS=$IFS
IFS=" " IFS=" "
# Must use eval or syntax error happens under dash
# Must use eval or syntax error happens under dash. The eval should use
# single quotes as older versions of busybox had a bug with double quotes and
# eval.
# Use 'caller 1' as we want one level up the stack as we should be called # Use 'caller 1' as we want one level up the stack as we should be called
# by one of the _debug* functions # by one of the _debug* functions
eval "_dbh_called=($(caller 1))"
eval '_dbh_called=($(caller 1))'
IFS=$_dbh_saveIFS IFS=$_dbh_saveIFS
_dbh_file=${_dbh_called[2]}
eval '_dbh_file=${_dbh_called[2]}'
if [ -n "${_script_home}" ]; then if [ -n "${_script_home}" ]; then
# Trim off the _script_home directory name # Trim off the _script_home directory name
_dbh_file=${_dbh_file#$_script_home/}
eval '_dbh_file=${_dbh_file#$_script_home/}'
fi fi
_dbh_function=${_dbh_called[1]}
_dbh_lineno=${_dbh_called[0]}
eval '_dbh_function=${_dbh_called[1]}'
eval '_dbh_lineno=${_dbh_called[0]}'
printf "%-40s " "$_dbh_file:${_dbh_function}:${_dbh_lineno}" printf "%-40s " "$_dbh_file:${_dbh_function}:${_dbh_lineno}"
} }

Loading…
Cancel
Save