zsh-workers
 help / color / mirror / code / Atom feed
From: Zoltan Hidvegi <hzoli@cs.elte.hu>
To: borsenkow.msk@sni.de
Cc: zsh-workers@math.gatech.edu
Subject: Re: Order of field splitting in zsh
Date: Thu, 16 Jan 1997 16:55:55 +0100 (MET)	[thread overview]
Message-ID: <199701161555.QAA10160@bolyai.cs.elte.hu> (raw)
In-Reply-To: <Pine.SV4.3.95.970116164954.21461M-100000@itsrm1.mow.sni.de> from Andrej Borsenkow at "Jan 16, 97 05:07:29 pm"

Andrej Borsenkow wrote:
> 
> POSIX.2 defines the following order of expansions in sh:
> 
> 1. tilde expansion, parameter expansion, command substitution, arithmetic
> expansion
> 2. field splitting (_after_ the above)
> 3. pathname expansion (globbing)
> 4. qoute removal.
> 
> It seems, that zsh (even if invoked as sh) does field splitting on result
> of command substitution  _immidiately_ after getting the value. The
> example is:
> 
> % sh #where sh is linked to zsh
> % args a$(echo a b)b${IFS::=:}
> 3
> aa
> bb
> %
> 
> (the third being null string). If I understand POSIX specs right, it
> should give _two_ arguments ('aa bb' and empty).
> 
> This example is obviously artificial; I fail currently to state if it can
> be a problem in real life or not. (Note, that ${var::=val} is illegal in
> POSIX; I use it to just demonstrate order of substitutions).

You are right but that can only cause problems when IFS changes in step
one, and under POSIX it can only happen when it was set to the empty string
previously.  I checked AT&T ksh and pdksh:

% ksh
$ args () { for i; do echo $i; done ; }
$ IFS=
$ args $(echo a b c)${IFS:=' '}
a b c
$ args $(echo a b c)${IFS:=' '}
a
b
c

As you see ksh behaves like zsh.  Bash behaves as POSIX requires.  But I do
not think it is a real problem, and the fix would just complicate the code
unnecessarily.  Note that both ksh I tested claims POSIX compilance.

Zoltan


  reply	other threads:[~1997-01-16 15:49 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-01-16 14:07 Andrej Borsenkow
1997-01-16 15:55 ` Zoltan Hidvegi [this message]
1997-01-22 15:58   ` Andrej Borsenkow
1997-01-22 21:59     ` Zoltan Hidvegi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=199701161555.QAA10160@bolyai.cs.elte.hu \
    --to=hzoli@cs.elte.hu \
    --cc=borsenkow.msk@sni.de \
    --cc=zsh-workers@math.gatech.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).