Checking Numeric Data with [0-9]+ in Korn

Checking Numeric Data with [0-9]+ in Korn

Post by Mike Delan » Fri, 20 Apr 2001 07:52:31

: >While it'd certainly be nice to be able to assume that ksh everywhere
: >is ksh93, the reality is that it's much more likely to be ksh88.
: All you need to do is to go to
: and download ksh93 binaries.
: I don't understand why this is hard to do?

Why is it so hard for you to consider whether a given "neat trick"
will work under both ksh88 and ksh93 before posting it, unqualified,
to as a solution to someone's ksh question when the
OP didn't specify which version of ksh they're using?

Just because *you* prefer ksh93 over ksh88 does not mean that everyone
is suddenly going to stop using ksh88 in favor of ksh93.

: And why should Linux
: not to include the true ksh93?

Don't know.  Don't care.  The fact remains that they ship pdksh.

: Have we agreed that, if $i passed the test:
: (( $i == 0 )) || (( $i ))
: Then $i is a number which can be handled by ksh ((...)).

No.  You've proven that $i contains either an arithmatic expression that ksh
is capable of evaluating, or the name of another variable which does
contain an arithmatic expression not that $i is a number.  

If that was written as:
  (( i == 0 )) || (( i ))
you'd have at least proven that $i contained an arithmatic expression.


"...Microsoft follows standards.  In much the same manner that fish follow
migrating caribou." "Now I have this image in my mind of a fish embracing and
extending a caribou." -- Paul Tomblin and Christian Bauernfeind in the SDM


Checking Numeric Data with [0-9]+ in Korn

Post by Geoff Clar » Sat, 21 Apr 2001 02:24:49

>$ printf "%P\n" [0-9]+
>The "%P" does not know extended regular expressions, for example:

s/does not know/only knows/

Quote:>$ printf "%P\n" '9\{3\}'        

That is a basic RE.  An equivalent extended RE is '9{3}' but %P doesn't
understand that either, so to be accurate all you can say is `The "%P"
only knows a subset of extended regular expressions'.