Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
Acme.Sh
Commits
eb623878
Unverified
Commit
eb623878
authored
Nov 03, 2019
by
neil
Committed by
GitHub
Nov 03, 2019
Browse files
Merge pull request #2546 from JohnVillalovos/master
Improve debug capabilities when using bash
parents
6140a3c2
bba5376a
Changes
1
Show whitespace changes
Inline
Side-by-side
acme.sh
View file @
eb623878
...
...
@@ -265,6 +265,37 @@ _usage() {
printf
"
\n
"
>
&2
}
__debug_bash_helper
()
{
# At this point only do for --debug 3
if
[
"
${
DEBUG
:-
$DEBUG_LEVEL_NONE
}
"
-lt
"
$DEBUG_LEVEL_3
"
]
;
then
echo
""
return
fi
# Return extra debug info when running with bash, otherwise return empty
# string.
if
[
-z
"
${
BASH_VERSION
}
"
]
;
then
echo
""
return
fi
# We are a bash shell at this point, return the filename, function name, and
# line number as a string
_dbh_saveIFS
=
$IFS
IFS
=
" "
# Must use eval or syntax error happens under dash
# Use 'caller 1' as we want one level up the stack as we should be called
# by one of the _debug* functions
eval
"_dbh_called=(
$(
caller
1
)
)"
IFS
=
$_dbh_saveIFS
_dbh_file
=
${
_dbh_called
[2]
}
if
[
-n
"
${
_script_home
}
"
]
;
then
# Trim off the _script_home directory name
_dbh_file
=
${
_dbh_file
#
$_script_home
/
}
fi
_dbh_function
=
${
_dbh_called
[1]
}
_dbh_lineno
=
${
_dbh_called
[0]
}
printf
"%-40s "
"
$_dbh_file
:
${
_dbh_function
}
:
${
_dbh_lineno
}
"
}
_debug
()
{
if
[
"
${
LOG_LEVEL
:-
$DEFAULT_LOG_LEVEL
}
"
-ge
"
$LOG_LEVEL_1
"
]
;
then
_log
"
$@
"
...
...
@@ -273,7 +304,8 @@ _debug() {
_syslog
"
$SYSLOG_DEBUG
"
"
$@
"
fi
if
[
"
${
DEBUG
:-
$DEBUG_LEVEL_NONE
}
"
-ge
"
$DEBUG_LEVEL_1
"
]
;
then
_printargs
"
$@
"
>
&2
_bash_debug
=
$(
__debug_bash_helper
)
_printargs
"
${
_bash_debug
}
$@
"
>
&2
fi
}
...
...
@@ -306,7 +338,8 @@ _debug2() {
_syslog
"
$SYSLOG_DEBUG
"
"
$@
"
fi
if
[
"
${
DEBUG
:-
$DEBUG_LEVEL_NONE
}
"
-ge
"
$DEBUG_LEVEL_2
"
]
;
then
_printargs
"
$@
"
>
&2
_bash_debug
=
$(
__debug_bash_helper
)
_printargs
"
${
_bash_debug
}
$@
"
>
&2
fi
}
...
...
@@ -338,7 +371,8 @@ _debug3() {
_syslog
"
$SYSLOG_DEBUG
"
"
$@
"
fi
if
[
"
${
DEBUG
:-
$DEBUG_LEVEL_NONE
}
"
-ge
"
$DEBUG_LEVEL_3
"
]
;
then
_printargs
"
$@
"
>
&2
_bash_debug
=
$(
__debug_bash_helper
)
_printargs
"
${
_bash_debug
}
$@
"
>
&2
fi
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment