Commit 7eb9a361 authored by Vitaly Lipatov's avatar Vitaly Lipatov

eget: update tty functions

parent 47d0f713
...@@ -52,33 +52,41 @@ isatty2() ...@@ -52,33 +52,41 @@ isatty2()
check_tty() check_tty()
{ {
isatty || return isatty || return
which tput >/dev/null 2>/dev/null || return is_command tput >/dev/null 2>/dev/null || return
# FreeBSD does not support tput -S # FreeBSD does not support tput -S
echo | tput -S >/dev/null 2>/dev/null || return echo | a= tput -S >/dev/null 2>/dev/null || return
[ -z "$USETTY" ] || return export USETTY="tput -S"
export USETTY=1
} }
: ${BLACK:=0} ${RED:=1} ${GREEN:=2} ${YELLOW:=3} ${BLUE:=4} ${MAGENTA:=5} ${CYAN:=6} ${WHITE:=7} : ${BLACK:=0} ${RED:=1} ${GREEN:=2} ${YELLOW:=3} ${BLUE:=4} ${MAGENTA:=5} ${CYAN:=6} ${WHITE:=7}
set_boldcolor() set_boldcolor()
{ {
[ "$USETTY" = "1" ] || return [ -n "$USETTY" ] || return
{ {
echo bold echo bold
echo setaf $1 echo setaf $1
} |tput -S } | $USETTY
}
set_color()
{
[ -n "$USETTY" ] || return
{
echo setaf $1
} | $USETTY
} }
restore_color() restore_color()
{ {
[ "$USETTY" = "1" ] || return [ -n "$USETTY" ] || return
{ {
echo op; # set Original color Pair. echo op; # set Original color Pair.
echo sgr0; # turn off all special graphics mode (bold in our case). echo sgr0; # turn off all special graphics mode (bold in our case).
} |tput -S } | $USETTY
} }
echover() echover()
{ {
[ -n "$verbose" ] || return [ -n "$verbose" ] || return
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment