installer: extract color sequences definition
This commit is contained in:
parent
62b8a70a7c
commit
eb453c6570
@ -1,10 +1,15 @@
|
|||||||
main() {
|
#!/bin/sh
|
||||||
# Use colors, but only if connected to a terminal, and that terminal
|
|
||||||
# supports them.
|
# Set up color sequences
|
||||||
|
setup_color() {
|
||||||
if which tput >/dev/null 2>&1; then
|
if which tput >/dev/null 2>&1; then
|
||||||
ncolors=$(tput colors)
|
ncolors=$(tput colors)
|
||||||
|
else
|
||||||
|
ncolors=0
|
||||||
fi
|
fi
|
||||||
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
|
|
||||||
|
# Only use colors if connected to a terminal that supports them
|
||||||
|
if [ -t 1 ] && [ $ncolors -ge 8 ]; then
|
||||||
RED="$(tput setaf 1)"
|
RED="$(tput setaf 1)"
|
||||||
GREEN="$(tput setaf 2)"
|
GREEN="$(tput setaf 2)"
|
||||||
YELLOW="$(tput setaf 3)"
|
YELLOW="$(tput setaf 3)"
|
||||||
@ -19,6 +24,10 @@ main() {
|
|||||||
BOLD=""
|
BOLD=""
|
||||||
NORMAL=""
|
NORMAL=""
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
main() {
|
||||||
|
setup_color
|
||||||
|
|
||||||
# Only enable exit-on-error after the non-critical colorization stuff,
|
# Only enable exit-on-error after the non-critical colorization stuff,
|
||||||
# which may fail on systems lacking tput or terminfo
|
# which may fail on systems lacking tput or terminfo
|
||||||
|
Loading…
Reference in New Issue
Block a user