Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: 'i' subscript flag
- X-seq: zsh-users 12753
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-users ml <zsh-users@xxxxxxxxxx>
- Subject: Re: 'i' subscript flag
- Date: Wed, 02 Apr 2008 09:41:06 -0700
- In-reply-to: <20080402153742.GA13167@okita>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <20080402153742.GA13167@okita>
On Apr 2, 5:37pm, Anthony Charles wrote:
}
} man zshparam says:
} "i Like `r', but gives the index of the match instead; this may not
} be combined with a second argument."
}
} I just wonder why this can't be combined with another flag which would
} be useful in this case for example:
}
} Saito% X="bar foo paz"
} Saito% print $X[(i)p*]
} 9
} Saito% print $X[(wi)p*]
} 9
}
} but one may expect to get '3'. Is this a design choice?
In some sense, yes. It has to do with the way that the internals of
parameter expansion were originally implemented (long before any kind
of reverse-subscripting was possible) and what it was reasonable to
layer on top of that.
Since you can always do e.g.
% print ${${=X}[(i)p*]}
3
it's not that significant a restriction.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author