3 quiet fname cmd args ...
\r
5 Runs the passed in command printing only "cmd" and "fname" unless an
\r
6 error occurs in which case it prints the whole command line and
\r
7 colorized program output. Useful for running compilation commands since
\r
8 it removes the cluter, making it easier to spot errors and warnings.
\r
11 # Copyright (c) 2008-2010 LoEE
\r
12 # This program is released under the new BSD license.
\r
14 if [ $# -lt 2 ]; then
\r
22 if [ "$TERM@" = "rxvt@" ]; then
\r
23 GREEN="printf \033[32m"
\r
24 RED="printf \033[31m"
\r
25 YELLOW="printf \033[33m" # this is not yellow :)
\r
26 NORM="printf \033[m\017"
\r
28 if [ "$OSTYPE@" = "msys@" ]; then
\r
29 OLDATTR=$(eecolor.exe)
\r
30 GREEN="eecolor.exe 0 10"
\r
31 RED="eecolor.exe 0 12"
\r
32 YELLOW="eecolor 0 14"
\r
33 NORM="eecolor.exe ${OLDATTR}"
\r
36 MSG="$(printf "%-16s $1" "$2")"
\r
39 printf "${MSG}\r" 1>&2
\r
44 # if we check $? we won't notice the warnings
\r
45 if [ $RET -ne 0 -o -s quiet.log ]; then
\r
47 if [ $RET -ne 0 ]; then
\r
58 printf "${MSG}\n" 1>&2
\r