Skip to content

Commit 8e72c8e

Browse files
committed
build
1 parent 0421d07 commit 8e72c8e

File tree

1 file changed

+22
-37
lines changed

1 file changed

+22
-37
lines changed

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

Lines changed: 22 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ else
1717
## Script was executed.
1818
dist_installer_cli_was_sourced="false"
1919
set -o errexit
20+
set -o errtrace
2021
set -o nounset
22+
set -o pipefail
2123
fi
2224

2325

@@ -828,6 +830,14 @@ if ! command -v stecho &>/dev/null ; then
828830
}
829831
fi
830832

833+
834+
835+
re_enable_xtrace_maybe() {
836+
if test "${xtrace:-}" = "1"; then
837+
set -o xtrace
838+
fi
839+
}
840+
831841
## Logging mechanism with easy customization of message format as well as
832842
## standardization on how the messages are delivered.
833843
## usage: log [info|notice|warn|error] "X occurred."
@@ -876,6 +886,7 @@ log(){
876886
;;
877887
*)
878888
log bug "Unsupported log type specified: '${log_type}'"
889+
re_enable_xtrace_maybe
879890
die 1 "Please report this bug."
880891
esac
881892
## uniform log format
@@ -890,6 +901,7 @@ log(){
890901
case "${log_type}" in
891902
bug|error)
892903
stecho "${log_full}" >&2
904+
re_enable_xtrace_maybe
893905
return 0
894906
;;
895907
null)
@@ -914,9 +926,7 @@ log(){
914926

915927
#sleep 0.1
916928

917-
if test "${xtrace:-}" = "1"; then
918-
set -o xtrace
919-
fi
929+
re_enable_xtrace_maybe
920930
}
921931

922932

@@ -996,8 +1006,13 @@ end_exit() {
9961006
## output all the logs to the screen before the background job is killed.
9971007
sleep 0.3
9981008
# shellcheck disable=SC2086
999-
kill -9 ${tail_pid}
1009+
kill -9 -- "${tail_pid}"
10001010
fi
1011+
1012+
true "INFO: Show log file locations at end of xtrace."
1013+
test -n "${log_file_user:-}" || true
1014+
test -n "${log_file_debug:-}" || true
1015+
10011016
## Exit with desired exit code.
10021017
exit "${last_exit}"
10031018
}
@@ -1049,13 +1064,11 @@ handle_exit() {
10491064
else
10501065
if [ "${last_exit}" -gt 128 ] && [ "${last_exit}" -lt 193 ]; then
10511066
signal_code=$((last_exit-128))
1052-
signal_caught="$(kill -l "${signal_code}")"
1067+
## 'kill --list' does not support end-of-options.
1068+
signal_caught="$(kill --list "${signal_code}")"
10531069
log error "Signal received: '${signal_caught}'"
10541070
fi
10551071
fi
1056-
## xtrace
1057-
printf "%s\n" "log_file_user: '${log_file_user}'" >/dev/null
1058-
printf "%s\n" "log_file_debug: '${log_file_debug}'" >/dev/null
10591072
## Print exit code.
10601073
log error "Installer exited with code: '${last_exit}'"
10611074
end_exit
@@ -3221,35 +3234,7 @@ get_transfer_cmd() {
32213234

32223235
## Set default traps
32233236
set_trap() {
3224-
local shebang
3225-
3226-
log info "Current PATH: '${PATH}'"
3227-
## Sometimes ps is not available, default to sh.
3228-
curr_shell="$(cat -- "/proc/$$/comm")"
3229-
## Get current shell from current process
3230-
## If the process if the file name, get its shell from shebang
3231-
## sometimes the process name is the base name of the script with some
3232-
## missing letters.
3233-
case "${0##*/}" in
3234-
${curr_shell}*)
3235-
## necessary glob because /bin/sh makes the file name
3236-
## appear with one letter less
3237-
shebang="$(head -1 "${0}")"
3238-
curr_shell="${shebang##*/}"
3239-
;;
3240-
esac
3241-
## TODO: This is not shown on CI.
3242-
log info "Current shell: '${curr_shell}'"
3243-
case "${curr_shell}" in
3244-
*bash|*ksh|*zsh)
3245-
if [ "${curr_shell}" = "bash" ]; then
3246-
set -o errtrace
3247-
set -o pipefail
3248-
fi
3249-
trap 'handle_exit $? ${LINENO:-}' ERR
3250-
;;
3251-
esac
3252-
trap 'handle_exit $? ${LINENO:-}' EXIT HUP INT QUIT ABRT ALRM TERM
3237+
trap 'handle_exit $? ${LINENO:-}' ERR EXIT HUP INT QUIT ABRT ALRM TERM
32533238
}
32543239

32553240

0 commit comments

Comments
 (0)