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:
parent
2167225d01
commit
e84645e597
31
functions.sh
31
functions.sh
@ -11,21 +11,6 @@ DEBUG=${DEBUG:-0}
|
|||||||
################################################################################
|
################################################################################
|
||||||
# Global functions
|
# 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
|
# Define colors
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
@ -106,22 +91,6 @@ else
|
|||||||
}
|
}
|
||||||
fi
|
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
|
# Display messages in color
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
@ -47,8 +47,13 @@ mountPoints() {
|
|||||||
# ${1} = full path to mountpoint;
|
# ${1} = full path to mountpoint;
|
||||||
# ${2} = if set will not umount; only kill processes in mount
|
# ${2} = if set will not umount; only kill processes in mount
|
||||||
umount_kill() {
|
umount_kill() {
|
||||||
# Turn off xtrace; but remember its current setting
|
if [ "${VERBOSE}" -le 2 ]; then
|
||||||
local xtrace=$(getXtrace) && set +x
|
# 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 mount_point="$(mountPoint "${1}")"
|
||||||
local kill_only="${2}"
|
local kill_only="${2}"
|
||||||
@ -99,8 +104,10 @@ umount_kill() {
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# Return xtrace to original state
|
if [ "$XTRACE_WAS_SET" == "true" ] ; then
|
||||||
setXtrace "${xtrace}"
|
true "$FUNCNAME: Restoring xtrace..."
|
||||||
|
set -x
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
kill_processes_in_mount() {
|
kill_processes_in_mount() {
|
||||||
|
Loading…
Reference in New Issue
Block a user