From: Johannes Sixt Date: Mon, 22 Oct 2007 11:35:30 GMT Subject: Re: [PATCH] Add some fancy colors in the test library when terminal supports it. Message-ID: <471C8B02.6080202@viscovery.net> In-Reply-To: <20071022112401.GE32763@artemis.corp> Pierre Habouzit schrieb: > On Mon, Oct 22, 2007 at 08:53:36AM +0000, Johannes Sixt wrote: >> Pierre Habouzit schrieb: >>> +say_color () { >>> + [ "$nocolor" = 0 ] && [ "$1" != '-1' ] && tput setaf "$1" >>> + shift >>> + echo "* $*" >>> + tput op >>> +} >> What if tput is not available, like on Windows? How about this (at the >> end of the file, so it can obey --no-color): > > I answered to it already in my first mail: if tput isn't available, > the command fails, and $? is non 0. and nocolor is set. Or color isn't > set to 't' for your proposal. I was too terse, sorry. I wanted to point out that if tput is not available, the second invocation will leave "tput: command not found" behind on stderr. Therefore, I proposed to make the definition of say_color() different depending on whether $color is set or not. Then you don't need to test for $color twice inside the function. -- Hannes