Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Bug with bash emulation regarding ':'



On Sun, 5 Feb 2012 20:11:33 +0000
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx> 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.

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.
In zsh I'm not sure there's even a corresponding place where we could do
splitting, even if we did something to fix the first difference, since
it would have to be after multsub() returned in order to get the
assignment to work as before, and at that point we don't want to screw
up white space that was originally quoted, about which we no longer have
any information.

I don't know quite what ought to trigger behaviour to change the first
difference, either (in principle I can fix this relatively easily, but
it makes the second problem much more noticeable). It might or might
not be the same condition as what triggers KSH_TYPESET, which in that
case might want to be on in sh emulation even though that's not bash
specific.

At this point I lost the will to live.  This will remain my definitive
position until further notice.

-- 
Peter Stephenson <pws@xxxxxxx>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog



Messages sorted by: Reverse Date, Date, Thread, Author