X-Git-Url: http://git.asbjorn.biz/?p=rapper.git;a=blobdiff_plain;f=bitbucket_lpc1768%2Fquiet;fp=bitbucket_lpc1768%2Fquiet;h=af06678e3223f89a888b646aaf5095d2431b2099;hp=d8bea3374b5b5b7a6326fdd800d2d5c50a7226bb;hb=f7b25fa1bf55e332b9aa2a60f1f0a059c38c1127;hpb=b53b7ca998f1ae39a58c20eea19a7ff3d7961f94 diff --git a/bitbucket_lpc1768/quiet b/bitbucket_lpc1768/quiet index d8bea33..af06678 100755 --- a/bitbucket_lpc1768/quiet +++ b/bitbucket_lpc1768/quiet @@ -1,62 +1,62 @@ -#!/bin/sh -HELP='Usage: - quiet fname cmd args ... - -Runs the passed in command printing only "cmd" and "fname" unless an -error occurs in which case it prints the whole command line and -colorized program output. Useful for running compilation commands since -it removes the cluter, making it easier to spot errors and warnings. - -' -# Copyright (c) 2008-2010 LoEE -# This program is released under the new BSD license. - -if [ $# -lt 2 ]; then - printf "$HELP" - exit -fi - -GREEN="" -RED="" -NORM="" -if [ "$TERM@" = "rxvt@" ]; then - GREEN="printf \033[32m" - RED="printf \033[31m" - YELLOW="printf \033[33m" # this is not yellow :) - NORM="printf \033[m\017" -fi -if [ "$OSTYPE@" = "msys@" ]; then - OLDATTR=$(eecolor.exe) - GREEN="eecolor.exe 0 10" - RED="eecolor.exe 0 12" - YELLOW="eecolor 0 14" - NORM="eecolor.exe ${OLDATTR}" -fi - -MSG="$(printf "%-16s $1" "$2")" -shift; - -printf "${MSG}\r" 1>&2 - -rm -f quiet.log -"$@" 2>> quiet.log -RET=$? -# if we check $? we won't notice the warnings -if [ $RET -ne 0 -o -s quiet.log ]; then - echo "$@" >& 2 - if [ $RET -ne 0 ]; then - $RED >& 2 - else - $YELLOW >& 2 - fi - cat quiet.log >& 2 - $NORM &> 2 - - exit $RET -else - $GREEN >& 2 - printf "${MSG}\n" 1>&2 - $NORM >& 2 -fi -rm quiet.log -exit $RET +#!/bin/sh +HELP='Usage: + quiet fname cmd args ... + +Runs the passed in command printing only "cmd" and "fname" unless an +error occurs in which case it prints the whole command line and +colorized program output. Useful for running compilation commands since +it removes the cluter, making it easier to spot errors and warnings. + +' +# Copyright (c) 2008-2010 LoEE +# This program is released under the new BSD license. + +if [ $# -lt 2 ]; then + printf "$HELP" + exit +fi + +GREEN="" +RED="" +NORM="" +if [ "$TERM@" = "rxvt@" ]; then + GREEN="printf \033[32m" + RED="printf \033[31m" + YELLOW="printf \033[33m" # this is not yellow :) + NORM="printf \033[m\017" +fi +if [ "$OSTYPE@" = "msys@" ]; then + OLDATTR=$(eecolor.exe) + GREEN="eecolor.exe 0 10" + RED="eecolor.exe 0 12" + YELLOW="eecolor 0 14" + NORM="eecolor.exe ${OLDATTR}" +fi + +MSG="$(printf "%-16s $1" "$2")" +shift; + +printf "${MSG}\r" 1>&2 + +rm -f quiet.log +"$@" 2>> quiet.log +RET=$? +# if we check $? we won't notice the warnings +if [ $RET -ne 0 -o -s quiet.log ]; then + echo "$@" >& 2 + if [ $RET -ne 0 ]; then + $RED >& 2 + else + $YELLOW >& 2 + fi + cat quiet.log >& 2 + $NORM &> 2 + + exit $RET +else + $GREEN >& 2 + printf "${MSG}\n" 1>&2 + $NORM >& 2 +fi +rm quiet.log +exit $RET