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

Re: PATCH and more remarks on parameter expansion docs



On Thu, Jan 03, 2013 at 11:42:17AM -0800, Bart Schaefer wrote:
> On Jan 3,  7:28am, Han Pingtian wrote:
> } Subject: Re: PATCH and more remarks on parameter expansion docs
> }
> } On Wed, Jan 02, 2013 at 08:46:44AM -0800, Bart Schaefer wrote:
> } > 
> } >      Note that splitting is applied to WORD in the assignment forms of
> } >      SPEC _before_ the assignment to NAME is performed.  This affects
> } >      the result of array assignments with the A flag.
> } 
> } I think it doesn't say this splitting _before_ assignments is only true
> } when (A) is used. Looks like if (A) wasn't used, splitting will _after_
> } the assignments
> 
> Ah, I see.  OK, I agree that it's imprecise about this.  It's imprecise
> but not in the way that you think:  The splitting is in fact done before
> the assignment in either case, but at that point the internals have both
> the expanded string and the split result available.  The (A) flag then
> determines which of those two values is used in the assignment.
> 
> I'm not sure whether in practice this can ever have a visible effect.  In
> theory if there were some oddity with the syntax of WORD that caused the
> splitting step to fail, then the NAME parameter would not be assigned,
> but I can't trivially produce an example.
> 
> On the other hand, when does this "mistake" in the documentation matter?
> Given what it says, what did you expect ${=xx::=foo   bar} to assign?
> 

Since ${=xx::=foo   bar} would result in two items foo and bar, but xx's
value is "foo   bar", so it looks like xx is assigned value "foo   bar",
then xx's value is splitted. 

But xx is a scalar here, so we cannot assign two value foo and bar to it
at the same time. So I think the value would be joined again before the
assignment? So I expect xx's value would be "foo bar"?

Thanks.



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