fc_install: Fix color determination code

The code is not a function, but apprease amoung functions making it a
bit out of place. So we move it down to the actual start after all
function definitions.

Additionally the 'are we connected to a pipe?' code is not working. Use
`test -t` instead of `test -p`.

Additionally check against stderr, not stdout, because all color ends on
stderr. See [1].

Additionally check for dump terminal and the usual NO_COLOR (also see [1]).

[1] https://clig.dev

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
This commit is contained in:
Fini Jastrow 2026-09-03 20:46:32 +02:00
parent bb6ae89ac2
commit e0bd379b8d

View file

@ -371,17 +371,6 @@ gh.download_asset() {
# script helpers
# --------------
if [ ! -p /dev/stdout ] && [ ! "${TERM:-unknown}" = "unknown" ]; then
_BYellow='\e[1;33m'
_BBlue='\e[1;94m'
_BRed='\e[1;31m'
_creset='\e[0m' # reset all attributes
else
_BYellow=''
_BBlue=''
_BRed=''
_creset=''
fi
msg.err() {
echo -e "${_BRed}ERROR:${_creset} $*" >&2
@ -475,4 +464,20 @@ main() {
echo "Nerd Fonts installer -- Version ${scriptversion}"
echo " -- Bash ${BASH_VERSION}"
if [ ! -t 2 ] || \
[ "${TERM:-unknown}" = "unknown" ] || \
[ "${TERM}" = "dumb" ] || \
[ -n "${NO_COLOR:-}" ]; then
_BYellow=''
_BBlue=''
_BRed=''
_creset=''
else
_BYellow='\e[1;33m'
_BBlue='\e[1;94m'
_BRed='\e[1;31m'
_creset='\e[0m'
fi
main "$@"