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

Re: path and += troubles



Bart Schaefer wrote:
> Exactly ... the problem is this:
> 
> schaefer<508> echo $1+=($2)
> zsh: no match
> schaefer<509> $1+=($2)
> schaefer<510> 
> 
> Where's my "no match" error in the second case?

(I'll abandon the other patch since that's not what you're worried
about.)

I'm having a hard time coming up with a combination of options and
arguments that does this.

% zsh -f           
% echo $1+=($2)
zsh: no matches found: +=()
% $1+=($2)
zsh: no matches found: +=()
% fn1() { echo $1+=($2); }
% fn1
fn1: no matches found: +=()
% fn2() { $1+=($2); }     
% fn2
fn2: no matches found: +=()
% fn2 path /usr/bin
fn2: missing end of name

(the last is supposed to look like what Steven was trying to do.)

But didn't you say the problem was with NULLGLOB?  Surely you'd expect
the presence of something looking like glob qualifiers (as long as
they're valid, and a lot of strings are valid global qualifiers) to make
the command turn out to be a boojum?

% setopt nullglob
% foo(.)
% $1+=(.)
% $1+=($2)
%

What am I missing?

One oddity is that +=($2) *does* give a "not an indentifier" error,
which is almost redundant with the current way of parsing assignments.
I think that's because the lexical analyser finds that "=" is not at the
start, so searches for an assignment.  Then it finds an empty identifier
and skips over the "+".  This means that it successfully meets the
condition for an ENVSTRING (we got to the "=" without finding an invalid
character).  Later, the actual assignment rejects this with contumely.
This is a small inconsistency.

-- 
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
Web page still at http://www.pwstephenson.fsnet.co.uk/



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