slitaz-base-files rev 187
libtaz.sh: cols should be fixes now
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Sat May 26 00:37:54 2012 +0200 (2012-05-26) |
parents | 7b0560247e33 |
children | 0933e039429b |
files | rootfs/lib/libtaz.sh |
line diff
1.1 --- a/rootfs/lib/libtaz.sh Fri May 25 16:42:57 2012 +0000 1.2 +++ b/rootfs/lib/libtaz.sh Sat May 26 00:37:54 2012 +0200 1.3 @@ -10,15 +10,12 @@ 1.4 # Copyright (C) 2012 SliTaz GNU/Linux - BSD License 1.5 # 1.6 1.7 -# Internationalization. 1.8 +# Internationalization. We can't export TEXTDOMAIN because this script 1.9 +# includes to other scripts with other TEXTDOMAIN exported 1.10 . /usr/bin/gettext.sh 1.11 -# We can't export TEXTDOMAIN because this script includes to other scripts 1.12 -# with other TEXTDOMAIN exported 1.13 -## TEXTDOMAIN='slitaz-base' 1.14 -## export TEXTDOMAIN 1.15 1.16 # xgettext (from Makefile) can't extract strings from above example: 1.17 -# gettext -d 'slitaz-base' 'Done' 1.18 +# gettext -d 'slitaz-base' 'Done' 1.19 # so, I define own function (and add it as option to xgettext to Makefile) 1.20 lgettext() { 1.21 gettext -d 'slitaz-base' $1 1.22 @@ -41,6 +38,11 @@ 1.23 done 1.24 [ "$HTTP_REFERER" ] && output="html" 1.25 1.26 +# Get terminal columns 1.27 +get_cols() { 1.28 + stty -a 2>/dev/null | head -n 1 | cut -d ";" -f 3 | awk '{print $2}' 1.29 +} 1.30 + 1.31 # Return command status. Default to colored console output. 1.32 status() { 1.33 local check=$? 1.34 @@ -52,7 +54,8 @@ 1.35 done=" <span style='color: $okcolor;'>$okmsg</span>" 1.36 error=" <span style='color: $ercolor;'>$ermsg</span>" ;; 1.37 *) 1.38 - cols=$(stty -a -F /dev/tty | head -n 1 | cut -d ";" -f 3 | awk '{print $2}') 1.39 + local cols=$(get_cols) 1.40 + [ "$cols" ] || cols=80 1.41 local scol=$(($cols - 10)) 1.42 done="\\033[${scol}G[ \\033[1;${okcolor}m${okmsg}\\033[0;39m ]" 1.43 error="\\033[${scol}G[ \\033[1;${ercolor}m${ermsg}\\033[0;39m ]" ;; 1.44 @@ -71,7 +74,9 @@ 1.45 case $output in 1.46 raw|gtk) local sepchar="-" && local cols="8" ;; 1.47 html) local sepchar="<hr />" ;; 1.48 - *) local cols=$(stty -a -F /dev/tty | head -n 1 | cut -d ";" -f 3 | awk '{print $2}') ;; 1.49 + *) 1.50 + local cols=$(get_cols) 1.51 + [ "$cols" ] || cols=80 ;; 1.52 esac 1.53 for c in $(seq 1 $cols); do 1.54 echo -n "$sepchar"