dUNIX 4.0b expr substr dropping leading zeros

From: Bob Fulton <SYSTMGR_at_Z2100.SCS.ZENITHE.COM>
Date: Wed, 17 Sep 1997 17:32:27 -0500 (CDT)

Running the sh shell(/bin/sh) on dUNIX 3.2D-1

#c=`expr substr 0089 2 3`
#set
.
.
c=089

Running same shell on dUNIX 4.0b
#c=`expr substr 0089 2 3`
#set
.
.
c=89

Under 4.0b, if the string is 0000 instead of 0089, the result is 0,
not the result of 000 under 3.2D-1. Placing " around the 0000 did not
change the result.

The above example is simplified from actual use for clarity.

I have been told by CSC that expr was modified for POSIX
compliance and to use expr from 3.2 as a workaround.

Would a POSIX expert please indicate whether the 4.0b version
of expr for the substr operand is indeed acting "correctly"?

TIA

Bob Fulton
bob.fulton_at_zenithe.com
Received on Thu Sep 18 1997 - 00:42:21 NZST

This archive was generated by hypermail 2.4.0 : Wed Nov 08 2023 - 11:53:36 NZDT