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

Re: More incompatibility :-) RE: PATCH: 3.1.9-dev-8: Re: Word splitting in zsh

On Feb 15,  9:17am, Andrej Borsenkow wrote:
} Subject: RE: More incompatibility :-) RE: PATCH: 3.1.9-dev-8: Re: Word spl
} Ehh ... I did not mean it actually. My concern was that in ${=$(...)}
} the `=' must not affect what happens inside of $(...).

It could be argued either way.  The doc says:

     Perform word splitting using the rules for SH_WORD_SPLIT during the
     evaluation of SPEC, but regardless of whether the parameter
     appears in double quotes;

The $(...) is in fact part of SPEC.  The problem is that, because ${=...}
is not implemented by actually toggling SH_WORD_SPLIT, it's surprising
what happens in cases like ${=x+$(setopt noshwordsplit; ...)}.

} What I believe
} should happen in case of ${x+${y}} - first, value is computed. It
} is either $x or $y - without any wordsplitting. Then `=' is applied
} to the result.

What you've described is exactly what zsh does (withOUT my patch).  This
is what causes ${1+"$@"} to behave strangely:  "$@" is expanded to an
array, but then the elements of the result are subject to splitting, if
splitting is enabled for the context (no matter why).

My patch attempted to make it the responsibility of multsub() to do any
splitting necessary on the right-hand-side of +/-, which works as long
as the entire RHS is a parameter substition.  However, In the case of
${1+some words "$@" more words}, prefork() [called by multsub()] just
doesn't do enough:  It yields "some words $1" ... "$@[-1] more words",
where sh would give "some" "words" "$1" ... "$@[-1]" "more" "words".

I've just about reached the conclusion that the RHS of these kinds of
expansions will have to be re-lexed in order to be wordsplit properly.
Once they've been lexed as a single word during the first pass, there
is no provision for differentiating the quoted and unquoted substrings
after expansion -- except within "nested" expansions, which doesn't
cover all the possible cases.

Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   

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