From patchwork Fri Mar 14 11:22:29 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Schwinge X-Patchwork-Id: 330282 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3D6EB2C00A2 for ; Fri, 14 Mar 2014 22:22:54 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:mime-version:content-type; q=dns; s=default; b=FHdsGcnMVNUf5wG1qvCeoJuT3w/kICvvu0g4tkRz5stSrhOEBi CEUrUFuqMxAn0min82e9TBX/L9rIBUaURF/ZCj0Ikv0QwtXzrQG/QL3BoZQxLpZ/ R3A/EgqAW8p5K3tfFrTM7P4cKgOJhPW4CITERq9+m0u11+ZW7AHE7GqGI= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:mime-version:content-type; s= default; bh=z79KAwt7zK6NWY6FTKtzUnZCrlM=; b=vmKNMfE0/u8G9WGCABf0 XaEBW5rBtXzbzdh9X4UZcc0nBJBBPO3dEoHtuEupfRKJIzc1PaBmLE5qfkPPN2YW iHSLFB+u/jV/Q2RwsADssDSZz5/LGA7F4qnHiSrfsE5JEHl5OwoqMMLrWZXrYAQM S9VMDc1ZbbOkMp7CYGEGdi0= Received: (qmail 15984 invoked by alias); 14 Mar 2014 11:22:46 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 15963 invoked by uid 89); 14 Mar 2014 11:22:45 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL, BAYES_00 autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 14 Mar 2014 11:22:43 +0000 Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1WOQCF-00074i-7y from Thomas_Schwinge@mentor.com ; Fri, 14 Mar 2014 04:22:39 -0700 Received: from SVR-IES-FEM-01.mgc.mentorg.com ([137.202.0.104]) by svr-orw-fem-01.mgc.mentorg.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Fri, 14 Mar 2014 04:22:39 -0700 Received: from feldtkeller.schwinge.homeip.net (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server id 14.2.247.3; Fri, 14 Mar 2014 11:22:36 +0000 From: Thomas Schwinge To: CC: , , , , Subject: config-ml.in: Robustify ac_configure_args parsing. User-Agent: Notmuch/0.9-101-g81dad07 (http://notmuchmail.org) Emacs/23.4.1 (x86_64-pc-linux-gnu) Date: Fri, 14 Mar 2014 12:22:29 +0100 Message-ID: <87fvmlkosq.fsf@schwinge.name> MIME-Version: 1.0 Hi! $ ../configure --enable-foo='--enable-a=1 --enable-b=2 --enable-c=3' [...] $ make configure-zlib config.status: creating Makefile config.status: executing default-1 commands ../../zlib/../config-ml.in: eval: line 142: unexpected EOF while looking for matching `'' ../../zlib/../config-ml.in: eval: line 143: syntax error: unexpected end of file make: *** [configure-zlib] Error 1 140 case $enableopt in 141 enable_shared | enable_static) ;; 142 *) eval $enableopt="$optarg" ;; 143 esac 144 ;; $ grep ac_configure_args < zlib/config.status ac_configure_args=" '--cache-file=./config.cache' '--enable-foo=--enable-a=1 --enable-b=2 --enable-c=3' '--enable-languages=c,c++,fortran,java,lto,objc' '--program-transform-name=s,y,y,' '--disable-option-checking' '--build=x86_64-unknown-linux-gnu' '--host=x86_64-unknown-linux-gnu' '--target=x86_64-unknown-linux-gnu' '--srcdir=../../zlib' 'build_alias=x86_64-unknown-linux-gnu' 'host_alias=x86_64-unknown-linux-gnu' 'target_alias=x86_64-unknown-linux-gnu'" These are quoted correctly; the error happens because the ac_configure_args parsing logic in config-ml.in will parse this as: 1. '--enable-foo=--enable-a=1 2. --enable-b=2 3. --enable-c=3' Below I'm proposing a patch using a shell function and eval to properly handle such configure arguments. Instead of a shell function, we could also use: eval set x "${ac_configure_args}" && shift for option do [...] done ..., as done in top-level configure.ac for baseargs etc., but as the config-ml.in script is sourced in different contexts, it is not obvious to me that we're permitted to overwrite the shell's positional parameters here. OK for trunk? (Will properly indent scan_arguments before commit.) commit bc6f99e9840994309eaf4e88679c3ba50d5e4918 Author: Thomas Schwinge Date: Thu Mar 13 19:54:58 2014 +0100 * config-ml.in: Robustify ac_configure_args parsing. Grüße, Thomas diff --git config-ml.in config-ml.in index 1198346..0cd7db3 100644 --- config-ml.in +++ config-ml.in @@ -105,10 +105,13 @@ ml_realsrcdir=${srcdir} # Scan all the arguments and set all the ones we need. +scan_arguments () +{ ml_verbose=--verbose -for option in ${ac_configure_args} +for option do - # strip single quotes surrounding individual options + # Strip single quotes surrounding individual options, that is, remove one + # level of shell quoting for these. case $option in \'*\') eval option=$option ;; esac @@ -139,7 +142,7 @@ do # Don't undo its work. case $enableopt in enable_shared | enable_static) ;; - *) eval $enableopt="$optarg" ;; + *) eval $enableopt='$optarg' ;; esac ;; --norecursion | --no-recursion) @@ -157,7 +160,7 @@ do *) optarg=yes ;; esac withopt=`echo ${option} | sed 's:^--::;s:=.*$::;s:-:_:g'` - eval $withopt="$optarg" + eval $withopt='$optarg' ;; --without-*) withopt=`echo ${option} | sed 's:^--::;s:out::;s:-:_:g'` @@ -165,6 +168,11 @@ do ;; esac done +} +# Use eval to properly handle configure arguments such as +# --enable-foo='--enable-a=1 --enable-b=2 --enable-c=3'. +eval scan_arguments "${ac_configure_args}" +unset scan_arguments # Only do this if --enable-multilib. if [ "${enable_multilib}" = yes ]; then @@ -860,7 +868,7 @@ if [ -n "${multidirs}" ] && [ -z "${ml_norecursion}" ]; then if eval ${ml_config_env} ${ml_config_shell} ${ml_recprog} \ --with-multisubdir=${ml_dir} --with-multisrctop=${multisrctop} \ - ${ac_configure_args} ${ml_config_env} ${ml_srcdiroption} ; then + "${ac_configure_args}" ${ml_config_env} ${ml_srcdiroption} ; then true else exit 1