[plug] problem found in "if" statement
Bernd Felsche
bernie at innovative.iinet.net.au
Wed Aug 27 13:26:52 WST 2003
On Wed, Aug 27, 2003 at 09:13:12AM +0800, Jon Miller wrote:
> I've found a problem in an "if" statement and cannot find a fix. The statement is
> if [ "$vMLSTAT" >= 0 ]; then
> .....
That looks like a syntax error to me; but I don't know which shell
you're using.
> .....
>
> fi
Try "-ge" instead of ">="
> I'm getting a unary operator expected. I've tried also the
> following and got a error message stating that [ : : integer
> expression expected
> if [ "$vMLSTAT" -lt 0 ]; then
> ......
> ......
> fi
That can happen if the variable isn't set to anything.
A "hack" around that problem is to prefix the "number" with a
literal zero e.g.
if [ 0"$vMLSTAT" -lt 0 ]; then
which works for positive numbers only!
Korn (and Bash, IIUC) shells allow type definitions for variables.
--
/"\ Bernd Felsche - Innovative Reckoning, Perth, Western Australia
\ / ASCII ribbon campaign | I'm a .signature virus!
X against HTML mail | Copy me into your ~/.signature
/ \ and postings | to help me spread!
More information about the plug
mailing list