From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28824 invoked by alias); 4 Aug 2010 15:33:47 -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: 28128 Received: (qmail 19748 invoked from network); 4 Aug 2010 15:33:43 -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=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received-SPF: pass (ns1.primenet.com.au: SPF record at spf-a.hotmail.com designates 65.55.34.157 as permitted sender) Message-ID: Content-Type: multipart/alternative; boundary="_3f5696c3-c12c-43a6-bc79-0c9900fba0a6_" X-Originating-IP: [70.53.45.9] From: John Lumby To: CC: , autoconf maillist , , Subject: RE: Fix testsuite errors due to shell quoted parameter expansion issue. Date: Wed, 4 Aug 2010 11:18:29 -0400 Importance: Normal In-Reply-To: References: <20100803203204.GG13690@gmx.de>,<4C588248.9050807@redhat.com>, MIME-Version: 1.0 X-OriginalArrivalTime: 04 Aug 2010 15:18:29.0236 (UTC) FILETIME=[4AE85340:01CB33E8] --_3f5696c3-c12c-43a6-bc79-0c9900fba0a6_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Re the statement since "$e" is quoted=2C it must not be elided I don't think that is correct. In fact "$e" *must* be elided - because = you juxtaposed it with the next token. eliding and quoting are orthogona= l. What you appear to be be expecting is that the effect of quoting one token = should somehow have some effect on interpretation of a special character (b= lank) in a subsequent unquoted token. I don't think that is expected beha= viour. The quoting of $e has the effect of quoting any special charact= ers inside *it*=2C of which there are none. your blank is unquoted. = Then word-spilling proceeds. What I find interesting is this bash -c 'declare -i length=3B f=3D" val" e=3D=3Bconcat=3D"$e"$f=3B length= =3D${#concat}=3B echo "length=3D $length"' 4 John Lumby > Date: Tue=2C 3 Aug 2010 23:21:02 +0200 > From: mikachu@gmail.com > To: eblake@redhat.com > CC: zsh-workers@zsh.org=3B Autoconf@gnu.org=3B libtool-patches@gnu.org > Subject: Re: Fix testsuite errors due to shell quoted parameter expansion= issue. >=20 > On 3 August 2010 22:55=2C Eric Blake wrote: > > [adding autoconf to document some shell bugs] > > > > On 08/03/2010 02:32 PM=2C Ralf Wildenhues wrote: > >> Interesting shell unportability: > >> > >> $ bash -c 'f=3D" val" e=3D=3B echo "$e"$f' > >> val > >> $ ksh -c 'f=3D" val" e=3D=3B echo "$e"$f' > >> val > >> > >> ksh93=2C dash=2C zsh all do it like ksh. Is that a bug in bash? > > > > Yes=3B adding bug-bash accordingly. According to POSIX: > > > > http://www.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html= #tag_18_06_05 > > > > "After parameter expansion ( Parameter Expansion )=2C command substitut= ion > > ( Command Substitution )=2C and arithmetic expansion ( Arithmetic > > Expansion )=2C 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=2C its expansion must undergo field splitting. = But > > since "$e" is quoted=2C it must not be elided even though empty. The > > result must be _two_ fields=2C as if you had done "echo '' 'val'". > > > > But it is _also_ a bug in zsh=3B adding zsh-workers accordingly. > > > > $ zsh -cvx 'f=3D" val" e=3D=3B echo "$e"$f' > > +zsh:1> f=3D' val' e=3D'' > > +zsh:1> echo ' val' > > val > > > > Oops - zsh only passed one argument to echo=2C with a leading space=2C > > instead of passing an empty argument and letting echo supply the space. > > ksh93=2C pdksh=2C and dash get it right (although dash doesn't use quo= tes > > in -vx output=2C hence my use of n() to force things to tell=3B n() is > > another way to expose the bash and zsh bugs). >=20 > zsh doesn't do word splitting by default=2C you can enable it with the = =3D modifier: > % zsh -fcvx 'f=3D" val" e=3D=3B echo "$e"$=3Df' > +zsh:1> f=3D' val' e=3D'' > +zsh:1> echo '' val > val >=20 > does what you want >=20 > Alternatively you can make zsh try to be closer to sh by setting > argv[0] to sh when executing it=2C or running 'emulate sh' as the first > command (and possibly other ways I don't know about): > % zsh -fcvx 'emulate sh=3Bf=3D" val" e=3D=3B echo "$e"$f' > +zsh:1> emulate sh > +zsh:1> f=3D' val' e=3D'' > +zsh:1> echo '' val > val >=20 > There's also --shwordsplit for this specific case: > % zsh --shwordsplit -fcvx 'f=3D" val" e=3D=3B echo "$e"$f' > +zsh:1> f=3D' val' e=3D'' > +zsh:1> echo '' val > val >=20 > (the -f above only avoids loading my .zshenv which would spam my output) >=20 > --=20 > Mikael Magnusson >=20 > _______________________________________________ > Autoconf mailing list > Autoconf@gnu.org > http://lists.gnu.org/mailman/listinfo/autoconf = --_3f5696c3-c12c-43a6-bc79-0c9900fba0a6_--