File tree Expand file tree Collapse file tree 1 file changed +19
-14
lines changed
Expand file tree Collapse file tree 1 file changed +19
-14
lines changed Original file line number Diff line number Diff line change @@ -410,10 +410,11 @@ get_su_cmd(){
410410
411411test_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 }
966967fi
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+
968982re_enable_xtrace_maybe () {
969983 if test " ${xtrace:- } " = " 1" ; then
970984 set -o xtrace
@@ -978,16 +992,7 @@ re_enable_xtrace_maybe() {
978992log (){
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:]" ) "
You can’t perform that action at this time.
0 commit comments