From: Chet Ramey <chet.ramey@case.edu>
To: Peter Stephenson <Peter.Stephenson@csr.com>
Cc: zsh-workers@zsh.org, chet.ramey@case.edu
Subject: Re: Bug with bash emulation regarding ':'
Date: Tue, 14 Feb 2012 18:30:21 -0500 [thread overview]
Message-ID: <4F3AEE8D.9050705@case.edu> (raw)
In-Reply-To: <20120214174154.36268595@pwslap01u.europe.root.pri>
On 2/14/12 12:41 PM, Peter Stephenson wrote:
> On Sun, 5 Feb 2012 20:11:33 +0000
> Peter Stephenson <p.w.stephenson@ntlworld.com> 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/
next prev parent reply other threads:[~2012-02-14 23:35 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-29 2:46 Felipe Contreras
2012-01-29 5:31 ` Benjamin R. Haskell
2012-01-29 13:44 ` Felipe Contreras
2012-01-29 14:25 ` Mikael Magnusson
2012-01-29 14:27 ` Mikael Magnusson
2012-01-29 18:38 ` Vincent Lefevre
2012-01-29 18:53 ` Mikael Magnusson
2012-01-29 19:01 ` Vincent Lefevre
2012-01-29 20:30 ` Peter Stephenson
2012-01-29 21:05 ` Mikael Magnusson
2012-01-30 22:15 ` Felipe Contreras
2012-01-30 22:18 ` Mikael Magnusson
2012-01-29 18:36 ` Peter Stephenson
2012-02-01 4:29 ` Bart Schaefer
2012-02-01 16:29 ` Bart Schaefer
2012-02-05 20:11 ` Peter Stephenson
2012-02-05 21:21 ` Bart Schaefer
2012-02-10 21:04 ` Peter Stephenson
2012-02-11 21:08 ` Bart Schaefer
2012-02-12 20:29 ` Peter Stephenson
2012-02-14 17:41 ` Peter Stephenson
2012-02-14 23:30 ` Chet Ramey [this message]
2012-02-15 12:36 ` Peter Stephenson
2012-02-19 23:45 ` Bart Schaefer
2012-02-20 8:48 ` Bart Schaefer
2012-02-20 10:59 ` Peter Stephenson
2012-02-20 17:09 ` Bart Schaefer
2012-01-30 19:22 ` Felipe Contreras
2012-02-10 11:08 Jilles Tjoelker
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=4F3AEE8D.9050705@case.edu \
--to=chet.ramey@case.edu \
--cc=Peter.Stephenson@csr.com \
--cc=zsh-workers@zsh.org \
/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).