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

Re: PATCH: Assorted parameter stuff

On Apr 15,  8:06am, Bart Schaefer wrote:
} I'll hold off committing this until a couple of you have applied it
} and say it seems OK.

Everybody must be on spring break.

On Apr 17,  4:45am, Bart Schaefer wrote:
} On Apr 16, 11:54pm, F. G. Marx wrote:
} }
} }     then> print ${foo[$mbegin[1],$mend[1]]}
} }     $> zsh: bad math expression: operand expected at `$mend[1]'
} I don't know exactly why this was broken, but my patch in 13992 fixes it.
} So maybe I should commit that patch after all.

I've now got one additional thing fixed.  In any version of zsh up to
4.0.1-pre-3, try this:

% foo='any random string'
% echo $foo[(i)ran

The correct output would be one of these:

    zsh: invalid subscript

    zsh: bad pattern: any random string[(i)ran

    zsh: bad pattern: string[(i)ran			(shwordsplit)

    any random string[(i)ran				(nobadpattern)

It's fairly difficult to get zsh to treat that open-bracket as anything
other than the start of a subscript, so the first of those is easiest,
and is what I've done.  However, that also means that:

% echo $foo[ran
zsh: invalid subscript

In 4.0.1-pre-2 that gives `any random string[ran' (regardless of the
setting of badpattern, which is arguably also wrong).

One additional question:  I think it'd be straightforward to make this
be parsed as all one word:

% echo $foo[(i)dom str]

I.e. the space inside the [ ] could implicitly be quoted.  Currently
it's necessary to use "$foo[(i)dom str]" to get an embedded space in a
subscript.  I can't think of any way in which such a change would break
a currently-working script.  Is it worth trying?

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