Merge remote-tracking branch 'origin/pr/8'
* origin/pr/8: fixed 'verbosity disabling bug' https://github.com/QubesOS/qubes-issues/issues/1100 Deprecated functions setVerboseMode, getXtrace, setXtrace and variable XTRACE, because those were broken and their only use case was function umount_kill. Re-implemented disabling xtrace in function umount_kill, if variable VERBOSE is lower than or equal 2.
This commit is contained in:
commit
5897b1a882
31
functions.sh
31
functions.sh
@ -11,21 +11,6 @@ DEBUG=${DEBUG:-0}
|
||||
################################################################################
|
||||
# Global functions
|
||||
################################################################################
|
||||
# ------------------------------------------------------------------------------
|
||||
# Set xtrace verbose mode (-x or)
|
||||
# ------------------------------------------------------------------------------
|
||||
XTRACE=
|
||||
function setVerboseMode() {
|
||||
# Cache xtrace current status so it can be restored on exit
|
||||
[[ ${-/x} != $- ]] && XTRACE=0 || XTRACE=1
|
||||
|
||||
if [ "${VERBOSE}" -ge 2 -o "${DEBUG}" -ge 2 ]; then
|
||||
set -x
|
||||
else
|
||||
set +x
|
||||
fi
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Define colors
|
||||
# ------------------------------------------------------------------------------
|
||||
@ -106,22 +91,6 @@ else
|
||||
}
|
||||
fi
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Return xtrace's current mode
|
||||
# 0 is enables (-x); 1 is disables (+x)
|
||||
# ------------------------------------------------------------------------------
|
||||
getXtrace() {
|
||||
[[ ${-/x} != $- ]] && echo 0 || echo 1
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Return xtrace to desired state
|
||||
# 0 is enables (-x); 1 is disables (+x)
|
||||
# ------------------------------------------------------------------------------
|
||||
setXtrace() {
|
||||
[[ "${1}" -eq 0 ]] && set -x || set +x
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Display messages in color
|
||||
# ------------------------------------------------------------------------------
|
||||
|
@ -47,8 +47,13 @@ mountPoints() {
|
||||
# ${1} = full path to mountpoint;
|
||||
# ${2} = if set will not umount; only kill processes in mount
|
||||
umount_kill() {
|
||||
# Turn off xtrace; but remember its current setting
|
||||
local xtrace=$(getXtrace) && set +x
|
||||
if [ "${VERBOSE}" -le 2 ]; then
|
||||
# If enabled, turn off xtrace and remember its current setting.
|
||||
if test -o xtrace ; then
|
||||
true "$FUNCNAME: Disabling xtrace, because variable VERBOSE (${VERBOSE}) is lower than or equal 2..."
|
||||
XTRACE_WAS_SET=true
|
||||
fi
|
||||
fi
|
||||
|
||||
local mount_point="$(mountPoint "${1}")"
|
||||
local kill_only="${2}"
|
||||
@ -99,8 +104,10 @@ umount_kill() {
|
||||
fi
|
||||
done
|
||||
|
||||
# Return xtrace to original state
|
||||
setXtrace "${xtrace}"
|
||||
if [ "$XTRACE_WAS_SET" == "true" ] ; then
|
||||
true "$FUNCNAME: Restoring xtrace..."
|
||||
set -x
|
||||
fi
|
||||
}
|
||||
|
||||
kill_processes_in_mount() {
|
||||
|
Loading…
Reference in New Issue
Block a user