- fix case:
- `CFLAGS='-O1 -O2'`
- `get-flag '-O*'`
- before `-O1`
- now `-O2`
- fix case:
- `CFLAGS='-W1,-O1'`
- `get-flag '-O*'`
- before `-W1,O1`
- now return 1
`get-flag march` == "i686" syntax still works.
---
eclass/flag-o-matic.eclass | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/eclass/flag-o-matic.eclass b/eclass/flag-o-matic.eclass
index e0b19e9..f670320 100644
--- a/eclass/flag-o-matic.eclass
+++ b/eclass/flag-o-matic.eclass
@@ -535,7 +535,7 @@ strip-unsupported-flags() {
# @DESCRIPTION:
# Find and echo the value for a particular flag. Accepts shell globs.
get-flag() {
- local f var findflag="$1"
+ local var findflag="${1}"
# this code looks a little flaky but seems to work for
# everything we want ...
@@ -543,11 +543,16 @@ get-flag() {
# `get-flag -march` == "-march=i686"
# `get-flag march` == "i686"
for var in $(all-flag-vars) ; do
- for f in ${!var} ; do
- if [ "${f/${findflag}}" != "${f}" ] ; then
- printf "%s\n" "${f/-${findflag}=}"
+ # reverse loop
+ set -- ${!var}
+ local i=$#
+ while [ $i -gt 0 ] ; do
+ local f="${!i}"
+ if [ "${f#-${findflag#-}}" != "${f}" ] ; then
+ printf "%s\n" "${f#-${findflag}=}"
return 0
fi
+ ((i--))
done
done
return 1
--
2.7.3