From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16695 invoked by alias); 14 Feb 2012 23:35:39 -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: 30219 Received: (qmail 15666 invoked from network); 14 Feb 2012 23:35:36 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.2 Received-SPF: pass (ns1.primenet.com.au: SPF record at case.edu designates 129.22.105.36 as permitted sender) Message-ID: <4F3AEE8D.9050705@case.edu> Date: Tue, 14 Feb 2012 18:30:21 -0500 From: Chet Ramey Reply-To: chet.ramey@case.edu Organization: ITS, Case Western Reserve University User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:8.0) Gecko/20111105 Thunderbird/8.0 MIME-Version: 1.0 To: Peter Stephenson CC: zsh-workers@zsh.org, chet.ramey@case.edu Subject: Re: Bug with bash emulation regarding ':' References: <20120129183644.6d49d237@pws-pc.ntlworld.com> <120131202909.ZM6076@torch.brasslantern.com> <120201082929.ZM7032@torch.brasslantern.com> <20120205201133.3bcd2b7f@pws-pc.ntlworld.com> <20120214174154.36268595@pwslap01u.europe.root.pri> In-Reply-To: <20120214174154.36268595@pwslap01u.europe.root.pri> X-Enigmail-Version: 1.3.4 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Junkmail-Whitelist: YES (by domain whitelist at mpv1.tis.cwru.edu) On 2/14/12 12:41 PM, Peter Stephenson wrote: > On Sun, 5 Feb 2012 20:11:33 +0000 > Peter Stephenson wrote: >> There's still a difference from bash... > > namely that in bash > > test_split_var= > : ${test_split_var:=$(echo "one > two > three")} > echo "$test_split_var" > > outputs the original string, with no splitting on the returned variable > from the command substitution. zsh does split the command substitution > before the assignment when in sh emulation (the same split array that > later gets substituted onto the command line), so the newlines turn into > spaces when the string is joined up again. Bash doesn't split word in ${parameter:OPword} because Posix says not to: "word shall be subjected to tilde expansion, parameter expansion, command substitution, and arithmetic expansion." A later interpretation adds quote removal to the list. > > However, > > test_split_var= > echo ${test_split_var:=$(echo "one > two > three")} > > does perform splitting, evidently after the assignment has been done > because the value assigned to test_split_var is (of course) as before. The same thing actually happens in both examples; you just look at the results of the expansion in the second case. The rhs gets expanded, but not split, assigned to test_split_var, and that becomes the result of the parameter expansion. Those results get split, since the param expansion doesn't occur within double quotes, and passed to `:' and echo as arguments. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, ITS, CWRU chet@case.edu http://cnswww.cns.cwru.edu/~chet/