fix(common): check before using tput with a fallback for colors
The latest release of devtools has included some pretty printing capabilities and fancy terminal stuff with the spinner and so on. It seems like the existing safeguards to disable this for incapable terminals were not enough though, therefore we saw two types of errors: - offload-build: ``` ==> Building in chroot for [extra] (x86_64)... tput: unknown terminal "unknown" tput: unknown terminal "unknown" tput: unknown terminal "unknown" ``` - repro builders: ``` ==> Successfully switched <package> to version <version> tput: No value for $TERM and no -T specified ERROR: Failed checkout <package> ``` The recently included fail option made this error populate to the command level and therefore increased its impact from a not so nice logging message to a more severe problem which made the command abort. We fix this by checking if tput is supported or else use the raw escape sequences instead of tput commands. Fixes:fedfc80
("feat(term): add terminal utils to handle a dynamic spinner") Fixes:66e83c9
("feat(version): pretty print and group together version check results") Fixes:d0dc0e1
("feat(search): add optional plain output formatting") Signed-off-by: Christian Heusel <christian@heusel.eu>
This commit is contained in:
parent
98bd7e3760
commit
e0a84aefc3
|
@ -34,9 +34,15 @@ export AUR_URL_SSH=aur@aur.archlinux.org
|
|||
# check if messages are to be printed using color
|
||||
if [[ -t 2 && "$TERM" != dumb ]] || [[ ${DEVTOOLS_COLOR} == always ]]; then
|
||||
colorize
|
||||
PURPLE="$(tput setaf 5)"
|
||||
DARK_GREEN="$(tput setaf 2)"
|
||||
UNDERLINE="$(tput smul)"
|
||||
if tput setaf 0 &>/dev/null; then
|
||||
PURPLE="$(tput setaf 5)"
|
||||
DARK_GREEN="$(tput setaf 2)"
|
||||
UNDERLINE="$(tput smul)"
|
||||
else
|
||||
PURPLE="\e[35m"
|
||||
DARK_GREEN="\e[32m"
|
||||
UNDERLINE="\e[4m"
|
||||
fi
|
||||
else
|
||||
# shellcheck disable=2034
|
||||
declare -gr ALL_OFF='' BOLD='' BLUE='' GREEN='' RED='' YELLOW='' PURPLE='' DARK_GREEN='' UNDERLINE=''
|
||||
|
@ -108,7 +114,9 @@ cleanup() {
|
|||
if [[ -n ${WORKDIR:-} ]] && $_setup_workdir; then
|
||||
rm -rf "$WORKDIR"
|
||||
fi
|
||||
tput cnorm >&2
|
||||
if tput setaf 0 &>/dev/null; then
|
||||
tput cnorm >&2
|
||||
fi
|
||||
exit "${1:-0}"
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue