From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5724 invoked by alias); 3 Aug 2010 21:07:14 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 28123 Received: (qmail 3332 invoked from network); 3 Aug 2010 21:07:12 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, SPF_HELO_PASS autolearn=ham version=3.3.1 Received-SPF: pass (ns1.primenet.com.au: SPF record at spf-1.redhat.com designates 209.132.183.28 as permitted sender) Message-ID: <4C588248.9050807@redhat.com> Date: Tue, 03 Aug 2010 14:55:36 -0600 From: Eric Blake Organization: Red Hat User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.7) Gecko/20100720 Fedora/3.1.1-1.fc13 Lightning/1.0b2pre Mnenhy/0.8.3 Thunderbird/3.1.1 MIME-Version: 1.0 To: libtool-patches@gnu.org, gary@gnu.org, Bash - Bug , zsh-workers@zsh.org, Autoconf@gnu.org Subject: Re: Fix testsuite errors due to shell quoted parameter expansion issue. References: <20100803203204.GG13690@gmx.de> In-Reply-To: <20100803203204.GG13690@gmx.de> X-Enigmail-Version: 1.1.2 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enig529CCA91BC0CB761938C7495" X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 --------------enig529CCA91BC0CB761938C7495 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable [adding autoconf to document some shell bugs] On 08/03/2010 02:32 PM, Ralf Wildenhues wrote: > Interesting shell unportability: >=20 > $ bash -c 'f=3D" val" e=3D; echo "$e"$f' > val > $ ksh -c 'f=3D" val" e=3D; echo "$e"$f' > val >=20 > ksh93, dash, zsh all do it like ksh. Is that a bug in bash? Yes; adding bug-bash accordingly. According to POSIX: http://www.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#t= ag_18_06_05 "After parameter expansion ( Parameter Expansion ), command substitution ( Command Substitution ), and arithmetic expansion ( Arithmetic Expansion ), the shell shall scan the results of expansions and substitutions that did not occur in double-quotes for field splitting and multiple fields can result." Since $f is not quoted, its expansion must undergo field splitting. But since "$e" is quoted, it must not be elided even though empty. The result must be _two_ fields, as if you had done "echo '' 'val'". But it is _also_ a bug in zsh; adding zsh-workers accordingly. $ zsh -cvx 'f=3D" val" e=3D; echo "$e"$f' +zsh:1> f=3D' val' e=3D'' +zsh:1> echo ' val' val Oops - zsh only passed one argument to echo, with a leading space, instead of passing an empty argument and letting echo supply the space. ksh93, pdksh, and dash get it right (although dash doesn't use quotes in -vx output, hence my use of n() to force things to tell; n() is another way to expose the bash and zsh bugs). $ ksh -cvx 'n() { echo $#; }; f=3D" val" e=3D; n "$e"$f' n() { echo $#; }; f=3D" val" e=3D; n ""$f+ f=3D' val' + e=3D'' + n '' val + echo 2 2 And meanwhile, I found a ksh93 parsing bug (don't know where to report that): $ ksh -c 'a(){ echo hi; }; a' ksh: syntax error at line 1: `}' unexpected $ ksh -c 'a() { echo hi; }; a' hi $ bash -c 'a(){ echo hi; }; a' hi $ /bin/sh -c 'a(){ echo hi; }; a' hi ksh is the only shell that requires a space between the ) and {, even though the ) is a metacharacter and should not need trailing space (even Solaris /bin/sh got that right). --=20 Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org --------------enig529CCA91BC0CB761938C7495 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.14 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/ iQEcBAEBCAAGBQJMWIJIAAoJEKeha0olJ0NqeGEH/2WJZK441IXonrz61tJNN9Cv 2FCRMMg+PW8zY+EBV5dBN1hApMku7UW12zWj2R32mKTjsNNre4B38/ATseGdik2B 5YYcerZbGC4/oTS8zXRC8iNxQXic8KTJl0mxk4g+fSRGJv3hlDGVJARF+fNp9sGE xb3Lqszfrlw7Le31uaI1qY9Ci0fe3du/McZCng1a6BvIhRfOMvVes5+Hfzdyvfb5 mlEdLCXbqEvRWGESHf/M9a3sO/TcLdqDFjvOmkTeBtoWw4Jjp93jXExk0u7Iymqw CT3n7Ea3Yt9gYxPMbMxnrRJ6oIJ5Dujh2I5/dDpDrXxyWfCqa0aRk3WOdUupGA8= =j+mq -----END PGP SIGNATURE----- --------------enig529CCA91BC0CB761938C7495--