DISQUS

DISQUS Hello!  The comments on this profile are unclaimed and thus are unverified.

Do they belong to you? Claim these comments.

nacho_a's picture

Unregistered

Feeds

aliases

  • nacho_a

nacho_a

9 months ago

in Checking if a variable is a number in ksh | Korn shell | Tech-Recipes on Tech-Recipes
What if $1 is 0?
You'll get FALSE!

From expr's man page:

EXIT STATUS
[...]
0 if the expression is neither NULL nor 0
1 if the expression is either NULL or 0

[...]
I'd use "-eq 2" instead of "-ne 0."

Thanks anyway, good tip.
1 reply
Mr. KIPS I wouldn't play with the exit status. Instead, change the arithmetic expression. Use expr $1 +1.
Returning? Login