Skip to content

Commit 0c6388b

Browse files
committed
build
1 parent b8a9e03 commit 0c6388b

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

usr/share/usability-misc/dist-installer-cli-standalone

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -410,10 +410,11 @@ get_su_cmd(){
410410

411411
test_run_as_target_user() {
412412
local root_output
413-
## Catches xtrace and hence variable root_output would be non-empty.
414-
#root_output="$(run_as_target_user timeout --kill-after 5 5 test -d /usr 2>&1)"
415-
## Therefore use a subshell and disable xtrace.
416-
root_output="$( ( set +x; run_as_target_user timeout --kill-after 5 5 test -d /usr ) 2>&1 )"
413+
## root_output would catch xtrace and hence variable root_output would be non-empty.
414+
## Therefore disabling xtrace.
415+
disable_xtrace
416+
root_output="$(run_as_target_user timeout --kill-after 5 5 test -d /usr 2>&1)"
417+
re_enable_xtrace_maybe
417418
if test -n "${root_output}"; then
418419
die 1 "${underline}run_as_target_user:${nounderline} 'sudo -u ${target_user}' test produced unexpected output: '${root_output}'"
419420
fi
@@ -965,6 +966,19 @@ if ! command -v stecho &>/dev/null ; then
965966
}
966967
fi
967968

969+
disable_xtrace() {
970+
if test "${xtrace:-}" = "1"; then
971+
set +o xtrace
972+
else
973+
case "${-}" in
974+
*x*)
975+
xtrace=1
976+
set +o xtrace
977+
;;
978+
esac
979+
fi
980+
}
981+
968982
re_enable_xtrace_maybe() {
969983
if test "${xtrace:-}" = "1"; then
970984
set -o xtrace
@@ -978,16 +992,7 @@ re_enable_xtrace_maybe() {
978992
log(){
979993
: "${log_level:="notice"}"
980994
## Avoid clogging output if log() is working alright.
981-
if test "${xtrace:-}" = "1"; then
982-
set +o xtrace
983-
else
984-
case "${-}" in
985-
*x*)
986-
xtrace=1
987-
set +o xtrace
988-
;;
989-
esac
990-
fi
995+
disable_xtrace
991996
log_type="${1:-notice}"
992997
## capitalize log level
993998
log_type_up="$(printf '%s' "${log_type}" | tr "[:lower:]" "[:upper:]")"

0 commit comments

Comments
 (0)