slitaz-base-files rev 161

libtaz.sh: some minor change and add comments/usage
author Christophe Lincoln <pankso@slitaz.org>
date Sat May 12 01:05:16 2012 +0200 (2012-05-12)
parents f359ebd9f721
children cc07c8fb5f4f
files rootfs/lib/libtaz.sh
line diff
     1.1 --- a/rootfs/lib/libtaz.sh	Fri May 11 18:53:55 2012 -0500
     1.2 +++ b/rootfs/lib/libtaz.sh	Sat May 12 01:05:16 2012 +0200
     1.3 @@ -35,11 +35,11 @@
     1.4  status() {
     1.5  	local check=$?
     1.6  	case $output in
     1.7 -		raw|gtk) 
     1.8 -			done=" $okmsg" 
     1.9 +		raw|gtk)
    1.10 +			done=" $okmsg"
    1.11  			error=" $ermsg" ;;
    1.12  		html)
    1.13 -			done=" <span class='done'>$okmsg</span>" 
    1.14 +			done=" <span class='done'>$okmsg</span>"
    1.15  			error=" <span class='error'>$ermsg</span>" ;;
    1.16  		*)
    1.17  			cols=$(stty -a -F /dev/tty | head -n 1 | cut -d ";" -f 3 | awk '{print $2}')
    1.18 @@ -79,10 +79,10 @@
    1.19  }
    1.20  
    1.21  # Indent text $1 spaces
    1.22 -indent() { 
    1.23 +indent() {
    1.24  	local in="$1"
    1.25  	shift
    1.26 -	echo -e "\033["$in"G $@"; 
    1.27 +	echo -e "\033["$in"G $@";
    1.28  }
    1.29  
    1.30  # Check if user is logged as root.
    1.31 @@ -93,13 +93,7 @@
    1.32  	fi
    1.33  }
    1.34  
    1.35 -yes_no() {
    1.36 -	[ "$autoyes" ] && true
    1.37 -	echo -n " ($(translate_query y)/$(translate_query N)) ? "
    1.38 -	read answer
    1.39 -	[ "$answer" == "$(translate_query y)" ] 
    1.40 -}
    1.41 -
    1.42 +# Gettextize yes/no.
    1.43  translate_query() {
    1.44  	case $1 in
    1.45  		y) gettext "y" ;;
    1.46 @@ -111,6 +105,14 @@
    1.47  	esac
    1.48  }
    1.49  
    1.50 -newline () {
    1.51 -	echo
    1.52 +# Usage: echo -n "The question" && confirm
    1.53 +confirm() {
    1.54 +	[ "$yes" ] && true
    1.55 +	echo -n " ($(translate_query y)/$(translate_query N)) ? "
    1.56 +	read answer
    1.57 +	[ "$answer" == "$(translate_query y)" ]
    1.58  }
    1.59 +
    1.60 +newline() {
    1.61 +	echo ""
    1.62 +}