Picking a character from a word
Richard A. O'Keefe
ok at quintus.UUCP
Wed Apr 27 20:30:28 AEST 1988
In article <50995 at sun.uucp>, guy at gorodish.Sun.COM (Guy Harris) writes:
> [I wrote]
> > Unfortunately, "expr substr" is a BSD-ism which has yet to find its way
> > into the SVID.
> Actually, "expr substr" is an AT&T-ism that they never documented and that they
> thought better of in S3 or so and deleted.
Thanks for the information. And thanks for the warning that
expr <string1> <relop> <string2>
won't work when <string1> is one of 'length', 'substr', 'index'.
However, deleting those operators did _NOT_ fix the general problem:
it doesn't work too well if <string1> = "(".
It should be noted that test(1) has similar problems: according to the SVID,
test $string
is supposed to succeed if $string is non-empty, e.g.
test "a"
is true, and
test ""
is false. But let $string be "-z", and you get an error message! You
would expect that using "-n $string" would eliminate this ambiguity,
but it introduces another: try string="="!.
The world is still waiting for a UNIX utility like test(1) or expr(1)
which works all the time.
More information about the Comp.unix.questions
mailing list