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

Re: 'i' subscript flag



On Wed, 02 Apr 2008 19:30:11 -0700
Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> Er, but the doc quite correctly says you can't do *anything* else with
> the (i) flag

No, it doesn't, as far as I can see, and it wouldn't be correct if it did.
It says:

  Like `tt(r)', but gives the index of the match instead; this may not be
  combined with a second argument.  On the left side of an assignment,
  behaves like `tt(r)'.  For associative arrays, the key part of each pair
  is compared to the pattern, and the first matching key found is the
  result.  On failure substitutes the length of the array plus one, as
  discussed under the description of `tt(r)', or the empty string for an
  associative array.

The only restriction is the end of the first sentence.  What that means is
you can't combine it with a second *subscript*, i.e. after a comma.  It's
not particularly clearly expressed since there's nothing here that
naturally corresponds to an "argument".

In any case, you can combine (i) with the (e), (n) and (b) flags.

> The (w) flag works just fine with (r) and (R), it's only (i) and (I)
> that are oddballs.

I fixed that.

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



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