slitaz-base-files rev 175

Update colorize to handle args easier
author Christian Mesh <meshca@clarkson.edu>
date Sat May 19 03:35:25 2012 -0500 (2012-05-19)
parents 159284129417
children c09b461ada93
files rootfs/lib/libtaz.sh testsuite.sh
line diff
     1.1 --- a/rootfs/lib/libtaz.sh	Thu May 17 14:53:51 2012 +0200
     1.2 +++ b/rootfs/lib/libtaz.sh	Sat May 19 03:35:25 2012 -0500
     1.3 @@ -87,12 +87,14 @@
     1.4  # Usage: colorize "Message" colorNB or use --color=NB option
     1.5  # when running a tool. Default to white/38 and no html or gtk.
     1.6  colorize() {
     1.7 -	: ${color=$2}
     1.8 +	: ${color=$1}
     1.9 +	shift
    1.10 +	local content="$@"
    1.11  	case $output in
    1.12 -		raw|gtk|html) echo "$1" ;;
    1.13 +		raw|gtk|html) echo "$content" ;;
    1.14  		*)
    1.15  			[ "$color" ] || color=38
    1.16 -			echo -e "\\033[1;${color}m${1}\\033[0;39m" ;;
    1.17 +			echo -e "\\033[1;${color}m${content}\\033[0;39m" ;;
    1.18  	esac
    1.19  	unset color
    1.20  }
     2.1 --- a/testsuite.sh	Thu May 17 14:53:51 2012 +0200
     2.2 +++ b/testsuite.sh	Sat May 19 03:35:25 2012 -0500
     2.3 @@ -14,9 +14,9 @@
     2.4  	boldify "Message"
     2.5  
     2.6  	echo -n "Checking libtaz.sh: colorize() "
     2.7 -	echo -n $(colorize "Message " 33)
     2.8 -	echo -n $(colorize "Message " 35)
     2.9 -	colorize "Message" 36
    2.10 +	echo -n $(colorize 33 "Message ")
    2.11 +	echo -n $(colorize 35 "Message ")
    2.12 +	colorize 36 "Message"
    2.13  
    2.14  	echo "Checking libtaz.sh: separator"
    2.15  	separator