slitaz-base-files rev 260

libtaz.sh: confirm() - variant more understandable for translators.
author Aleksej Bobylev <al.bobylev@gmail.com>
date Tue Dec 02 02:57:09 2014 +0200 (2014-12-02)
parents f1371340fe5b
children a410c3feb222
files rootfs/lib/libtaz.sh
line diff
     1.1 --- a/rootfs/lib/libtaz.sh	Thu Nov 27 16:26:58 2014 +0200
     1.2 +++ b/rootfs/lib/libtaz.sh	Tue Dec 02 02:57:09 2014 +0200
     1.3 @@ -171,12 +171,20 @@
     1.4  	esac
     1.5  }
     1.6  
     1.7 -# Usage: echo -n "The question" && confirm
     1.8 +# Usage 1: echo -n "The question"; confirm
     1.9 +# Usage 2: confirm "The question (y/N)?"
    1.10  confirm() {
    1.11 -	[ "$yes" ] && true
    1.12 -	echo -n " ($(translate_query y)/$(translate_query N)) ? "
    1.13 -	read answer
    1.14 -	[ "$answer" == "$(translate_query y)" ]
    1.15 +	if [ -n "$yes" ]; then
    1.16 +		true
    1.17 +	else
    1.18 +		if [ -n "$1" ]; then
    1.19 +			echo -n "$1 "
    1.20 +		else
    1.21 +			echo -n " ($(translate_query y)/$(translate_query N)) ? "
    1.22 +		fi
    1.23 +		read answer
    1.24 +		[ "$answer" == "$(translate_query y)" ]
    1.25 +	fi
    1.26  }
    1.27  
    1.28  # Log activities. $activity should be set by the script. The log format