Commit 657ba476 authored by Vitaly Lipatov's avatar Vitaly Lipatov

add check_tty, print command in stderr

parent 38f4c705
...@@ -30,6 +30,7 @@ load_helper epm-sh-functions ...@@ -30,6 +30,7 @@ load_helper epm-sh-functions
set_sudo set_sudo
check_tty
############################# #############################
......
...@@ -27,11 +27,17 @@ isatty() ...@@ -27,11 +27,17 @@ isatty()
test -t 1 test -t 1
} }
check_tty()
{
isatty || return
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()
{ {
isatty || return [ -n "$USETTY" ] || return
{ {
echo bold echo bold
echo setaf $1 echo setaf $1
...@@ -40,7 +46,7 @@ set_boldcolor() ...@@ -40,7 +46,7 @@ set_boldcolor()
restore_color() restore_color()
{ {
isatty || 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).
...@@ -77,7 +83,7 @@ showcmd() ...@@ -77,7 +83,7 @@ showcmd()
[ "$UID" = 0 ] && PROMTSIG="#" [ "$UID" = 0 ] && PROMTSIG="#"
echo " $PROMTSIG $@" echo " $PROMTSIG $@"
restore_color restore_color
fi fi >&2
} }
# Print command line and run command line # Print command line and run command line
......
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