Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 16 May 2005 04:30:13 +1000 (EST)
From:      Ian Smith <smithi@nimnet.asn.au>
To:        freebsd-questions@freebsd.org
Subject:   simple? sh problen
Message-ID:  <Pine.BSF.3.96.1050516041643.18128B-100000@gaia.nimnet.asn.au>

next in thread | raw e-mail | index | archive | help
Hopefully not too OT .. the only silly question being the unasked one ..

How do I test whether a sh argument is an integer or not, so as to avoid
failing on a syntax error from otherwise working code such as:

 [ $3 -lt 10 -o $3 -gt 600 ] && echo "$0 $1 $2: $3 invalid" && exit 1

when $3 is a non-integer argument?  Do I need to delve into awk and REs,
or is there something more simple I've missed in mans test, expr, etc?

Cheers, Ian



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.3.96.1050516041643.18128B-100000>