Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: test if a parameter is numeric
- X-seq: zsh-users 11213
- From: Stephane Chazelas <Stephane_Chazelas@xxxxxxxx>
- To: Lydgate <zsh@xxxxxxxxxxxxxxxxxx>, zsh-users@xxxxxxxxxx
- Subject: Re: test if a parameter is numeric
- Date: Tue, 20 Feb 2007 21:35:56 +0000
- In-reply-to: <20070220202001.GA6319@xxxxxxxxxxxxxxx>
- Mail-followup-to: Lydgate <zsh@xxxxxxxxxxxxxxxxxx>, zsh-users@xxxxxxxxxx
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <Xns98D2ADD16C100zzappergmailcom@xxxxxxxxxxx> <070209182939.ZM18654@xxxxxxxxxxxxxxxxxxxxxx> <003d01c74d3f$3bbd7960$6600000a@venti> <E1HG3Bl-0007Ge-DM@xxxxxxxxxx> <E1HJIfJ-0002Ok-Ql@xxxxxxxxxx> <20070220075226.GA11608@DervishD> <20070220202001.GA6319@xxxxxxxxxxxxxxx>
- Sender: Stephane Chazelas <stephane_chazelas@xxxxxxxx>
On Tue, Feb 20, 2007 at 08:20:01PM +0000, Stephane Chazelas wrote:
> On Tue, Feb 20, 2007 at 08:52:26AM +0100, DervishD wrote:
> [...]
> > [[ "$1" == ]]
> >
> > And the "[[" is NOT portable, either, it's a zsh thing (and probably
> > bash has too, I don't know, but AFAIK is not POSIX/SuS).
> [...]
>
> rather from ksh.
>
> POSIXly, you'd write
>
> case $1 in
> ("" | *[!0-9]) echo not a number;;
("" | *[!0-9]*) echo not a number;;
sorry.
[...]
> Note that zsh extended globbing patterns, though with a
> different syntax are functionnaly equivalent to regexps and has
> may additions over it.
>
> ERE -> zsh
> . ?
> * #
> + ##
> ? (|...)
> (...) (...)
> (..|..)(..|..)
[...]
It can also be said of ksh's globs (same as bash with extglob or
zsh with kshglob)
ERE -> ksh
. ?
a* *(a)
a+ +(a)
a? ?(a)
(a|b) @(a|b)
recent versions of ksh have more features. There are features in
ksh globs that are not available in zsh's ones like {3}(...),
and likewise in the other direction like <1-10>.
ksh's @(a*b&*c*) can be written in zsh: a*b~^*c* (and not not),
I don't think bash has an equivalent
--
Stéphane
Messages sorted by:
Reverse Date,
Date,
Thread,
Author