Passing a --cross-cc-cflags-* option with a value that contains a '=' causes configure to exit:
$ ./configure --cross-cc-cflags-arm='-DFOO=bar' ERROR: Passed bad --cross-cc-FOO option This is an annoying limitation since '=' is frequently found in CFLAGS. This is caused by this line in the CC options parsing loop: --cross-cc-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-cc-FOO option" The '[!a-zA-Z0-9_-]' pattern matches the first '=' in the option and the '=' pattern matches the other one. The '*' patterns then match the rest. The intent seems to be that we only want characters from the range [a-zA-Z0-9_-] in the option name. Shell pattern matching isn't powerful enough to do that with a single expression. First, isolate the option name, i.e. before the first '=' character, with a regular expression. Only error out if there's at least one unwanted character in the name. Fixes: d75402b5ee29 ("configure: add support for --cross-cc-FOO") Cc: alex.ben...@linaro.org Signed-off-by: Greg Kurz <gr...@kaod.org> --- configure | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/configure b/configure index 3a926ff8fc23..61a415e4dc61 100755 --- a/configure +++ b/configure @@ -472,16 +472,23 @@ for opt do ;; --disable-debug-info) debug_info="no" ;; - --cross-cc-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-cc-FOO option" - ;; - --cross-cc-cflags-*) cc_arch=${opt#--cross-cc-cflags-}; cc_arch=${cc_arch%%=*} - eval "cross_cc_cflags_${cc_arch}=\$optarg" - cross_cc_vars="$cross_cc_vars cross_cc_cflags_${cc_arch}" - ;; - --cross-cc-*) cc_arch=${opt#--cross-cc-}; cc_arch=${cc_arch%%=*} - cc_archs="$cc_archs $cc_arch" - eval "cross_cc_${cc_arch}=\$optarg" - cross_cc_vars="$cross_cc_vars cross_cc_${cc_arch}" + --cross-cc-*=*) + optname=$(expr "x$opt" : 'x\([^=]*\)=.*') + case "$optname" in + *[!a-zA-Z0-9_-]*) error_exit "Passed bad $optname option" + ;; + esac + case "$opt" in + --cross-cc-cflags-*) cc_arch=${opt#--cross-cc-cflags-}; cc_arch=${cc_arch%%=*} + eval "cross_cc_cflags_${cc_arch}=\$optarg" + cross_cc_vars="$cross_cc_vars cross_cc_cflags_${cc_arch}" + ;; + --cross-cc-*) cc_arch=${opt#--cross-cc-}; cc_arch=${cc_arch%%=*} + cc_archs="$cc_archs $cc_arch" + eval "cross_cc_${cc_arch}=\$optarg" + cross_cc_vars="$cross_cc_vars cross_cc_${cc_arch}" + ;; + esac ;; esac done -- 2.31.1