From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13579 invoked from network); 16 Jan 1997 15:49:26 -0000 Received: from euclid.skiles.gatech.edu (list@130.207.146.50) by coral.primenet.com.au with SMTP; 16 Jan 1997 15:49:26 -0000 Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id KAA29921; Thu, 16 Jan 1997 10:54:46 -0500 (EST) Resent-Date: Thu, 16 Jan 1997 10:54:46 -0500 (EST) From: Zoltan Hidvegi Message-Id: <199701161555.QAA10160@bolyai.cs.elte.hu> Subject: Re: Order of field splitting in zsh In-Reply-To: from Andrej Borsenkow at "Jan 16, 97 05:07:29 pm" To: borsenkow.msk@sni.de Date: Thu, 16 Jan 1997 16:55:55 +0100 (MET) Cc: zsh-workers@math.gatech.edu Organization: Dept. of Comp. Sci., Eotvos University, Budapest, Hungary Phone: (36 1)2669833 ext: 2667, home phone: (36 1) 2752368 X-Mailer: ELM [version 2.4ME+ PL27 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Resent-Message-ID: <"-uZZc.0.SJ7.5zato"@euclid> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/2800 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu 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