-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Steve Long schrieb:
> René 'Necoro' Neumann wrote:
>> cmake-utils_src_enable python => -DENABLE_python=...
>>
>> Wanted would be that it returned -DENABLE_PYTHON=...
>>
>> I'm not into bash scripting that much, so I do not know a way to do so -
>> but I guess someone else is ;)
>>
> Unfortunately BASH doesn't support ksh93 or zsh style casting to uppercase.
> The best way really is via tr:
> alias toUpper='tr [[:lower:]] [[:upper:]]'
> alias toLower='tr [[:upper:]] [[:lower:]]'
> 
> (er aliases don't normally work in scripts, but you get the idea.) Bear in
> mind that tr reads stdin and writes to stdout. It has the advantage of
> being locale-safe. Every other method I've looked at is much slower and
> only works with ASCII.
> 
> A function wouldn't be too hard:
> toUpper() {
>         for i; do
>         echo "$i" |tr [[:lower:]] [[:upper:]]
>         done
> }
> 
> Usage depends on the parameters you pass.
> var=$(toUpper $var) # for single vars with no newlines in

This is right the version I've chosen ... so with the help of Steve: a
small patch ;)

Regards,
Necoro
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD4DBQFHM5uv4UOg/zhYFuARAuELAJjnlDCFDMm3e2mJqYuyT4nkFoaaAJ4go9qp
Qca9r8Y7LpD0YSSylUh2BQ==
=517n
-----END PGP SIGNATURE-----
--- cmake-utils.eclass.old      2007-11-09 00:25:49.000000000 +0100
+++ cmake-utils.eclass  2007-11-09 00:14:47.000000000 +0100
@@ -23,11 +23,17 @@
 
 EXPORT_FUNCTIONS src_compile src_test src_install
 
+# Internal funcion used by _use_me_now. Converts string to upper case.
+_to_upper() {
+       debug-print-function $FUNCNAME $*
+       echo "$1" | tr "[[:lower:]]" "[[:upper:]]"
+}
+
 # Internal function use by cmake-utils_use_with and cmake-utils_use_enable
 _use_me_now() {
        debug-print-function $FUNCNAME $*
        [[ -z $2 ]] && die "cmake-utils_use-$1 <USE flag> [<flag name>]"
-       echo "-D$1_${3:-$2}=$(use $2 && echo ON || echo OFF)"
+       echo "-D$1_${3:-$(_to_upper $2)}=$(use $2 && echo ON || echo OFF)"
 }
 
 # @FUNCTION: cmake-utils_use_with

Reply via email to