Both filter-flags and replace-flags in flag-o-matic.eclass seem to remove one character from the end of the FLAGS variables if the flag they are supposed to remove or replace is not present in the FLAGS variable. Mostly this causes annoyance (e.g. option -pip not valid) but it did stop me from compiling openoffice alltogether because the flags were broken. I have changed the lines reading CFLAGS="${CFLAGS:1:${#CFLAGS}-2}" to be CFLAGS="${CFLAGS:1:${#CFLAGS}-1}" instead, but I'm not sure if that is the proper fix for this situation. Reproducible: Always Steps to Reproduce: 1. run test script included in additional information field 2. observe breakage 3. emerge openoffice to see breakage in real-life action Actual Results: -O -pipe test.sh: line 109: ${#CXXFLAGS}-2: substring expression < 0 -O -pip -fno-strict-aliasing -O -pip -fno-strict-aliasin -O2 -pip -fno-strict-aliasi -O2 -pip -fno-strict-aliasi Expected Results: -O -pipe test.sh: line 109: ${#CXXFLAGS}-1: substring expression < 0 -O -pipe -fno-strict-aliasing -O -pipe -fno-strict-aliasing -O2 -pipe -fno-strict-aliasing I have used the following test script: #!/bin/sh source /usr/portage/eclass/flag-o-matic.eclass export CFLAGS="-O -pipe" echo $CFLAGS filter-flags "-bozo" append-flags "-fno-strict-aliasing" echo $CFLAGS replace-flags "-O3" "-O2" echo $CFLAGS replace-flags "-O" "-O2" echo $CFLAGS
Re-assigned to dev-portage team.
the -2 is correct because if you look in the functions, the very first thing they do is stick a space onto the beginning and onto the end: CFLAGS=" ${CFLAGS} " so the final CFLAG will have a space at the beginning and end and thus will need to have 2 bytes chopped off i dont know what's wrong on your box but it works fine here: root@vapier 0 root # cat test.sh #!/bin/bash source /usr/portage/eclass/flag-o-matic.eclass export CFLAGS="-O -pipe" echo $CFLAGS filter-flags "-bozo" append-flags "-fno-strict-aliasing" echo $CFLAGS replace-flags "-O3" "-O2" echo $CFLAGS replace-flags "-O" "-O2" echo $CFLAGS root@vapier 0 root # ./test.sh -O -pipe -O -pipe -fno-strict-aliasing -O -pipe -fno-strict-aliasing -O2 -pipe -fno-strict-aliasing
I have now found that the problem is due to not having a full Gentoo system. I've upgraded an existing system to Gentoo, and bash was one of the applications I had not yet updated using Gentoo. Patch-ID bash205b-004 explains the problem as it deals with calculating the length of a string in bash with leading spaces. This was exactly the problem I was having. emerging bash from Gentoo has solved the problem.
ah, that'll do it :)
user's bash was old (not from Gentoo)