Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=frugalware-current.git;a=commitdiff;h=698ac864bb997e5f3b76b46bae8447cc899372ad

commit 698ac864bb997e5f3b76b46bae8447cc899372ad
Author: Michel Hermier <herm...@frugalware.org>
Date:   Wed Jan 5 22:01:14 2011 +0100

util.sh: Introduce Flowerstr and Fupperstr.

* Introduce this facility to reduce duplication over util.sh.
NOTE: we could have used the bash sytax ${foo,,} and ${foo^^} to
achieve the same thing, but this way is more portable.

diff --git a/source/include/util.sh b/source/include/util.sh
index 57ad90b..8b4b52f 100644
--- a/source/include/util.sh
+++ b/source/include/util.sh
@@ -152,6 +152,20 @@ Fuse()
}

###
+# * Flowerstr(): Lower a string. Parameters: The string to lower.
+###
+Flowerstr() {
+       echo -nE "$@"|tr '[:upper:]' '[:lower:]'
+}
+
+###
+# *Fupperstr(): Upper a string. Parameters: The string to upper.
+###
+Fupperstr() {
+       echo -nE "$@"|tr '[:lower:]' '[:upper:]'
+}
+
+###
# * __Faddsubpkg(): Internal usage only. Registers one new subpkg per call.
# Takes any number of parameters. Each parameter must be in the form of
# "key:value". The key is what the variable would be called if it were a
@@ -1437,11 +1451,9 @@ Fsplit()
###
check_option() {
local i
-       for i in ${optio...@]}; do
-               local uc=`echo $i | tr '[:lower:]' '[:upper:]'`
-               local lc=`echo $i | tr '[:upper:]' '[:lower:]'`
-               if [ "$uc" = "$1" -o "$lc" = "$1" ]; then
-                       echo $1
+       for i in "${optio...@]}"; do
+               if [ `Flowerstr "$i"` = "$1" -o `Fupperstr "$i"` = "$1" ]; then
+                       echo -nE "$1"
return
fi
done
@@ -1457,11 +1469,11 @@ check_option() {
Fmsgfmt() {
local llang mofile pofile slang

-       if echo $2|grep -q _ ; then
+       if echo -nE "$2"|grep -q _ ; then
llang="$2"
slang=`echo $llang|cut -d _ -f 1`
else
-               llang=${2}_`echo $2|tr [:lower:] [:upper:]`
+               llang="${2}_`Fupperstr \"$2\"`"
slang="$2"
fi

@@ -1479,10 +1491,9 @@ Fmsgfmt() {
# Fextract pacman.tar.gz.
###
Fextract() {
-       local cmd file tmp
+       local cmd file
file="${1}"
-       tmp="$(echo "${file}" | tr 'A-Z' 'a-z')"
-       case "${tmp}" in
+       case `Flowerstr "$file"` in
*.tar.bz2|*.tbz2)
cmd="tar $_F_extract_taropts --use-compress-program=bzip2 -xf $file" ;;
*.tar.gz|*.tar.z|*.tgz)
_______________________________________________
Frugalware-git mailing list
Frugalware-git@frugalware.org
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to