Ultrix 4.1 awk substr/split bug
Ian! D. Allen [CGL]
idallen at watcgl.waterloo.edu
Fri Feb 8 06:58:23 AEST 1991
#!/bin/sh
# This shows that substr and split interact in a bad way on Ultrix.
# This appears in every version of Ultrix I have tried here, including
# the very latest Ultrix 4.1 (RISC).
# (Same bug shows up on several O/S, including 4.3 BSD.)
# idallen at watcgl.waterloo.edu
#
exec awk '
BEGIN {
s = "xxxxxxxxxarg1 arg2"
print "substring is", substr(s,10,20)
n = split(substr(s,10,20),x," ")
print "n is", n
print "x[1] is", x[1]
print "x[2] is", x[2]
t = substr(s,10,20)
n = split(t,x," ")
print "n is", n
print "x[1] is", x[1]
print "x[2] is", x[2]
}' </dev/null
Output:
substring is arg1 arg2
n is 2
x[1] is arg1 arg2 <== wrong
x[2] is arg2
n is 2
x[1] is arg1 <== right
x[2] is arg2
--
-IAN! (Ian! D. Allen) idallen at watcgl.uwaterloo.ca idallen at watcgl.waterloo.edu
[129.97.128.64] Computer Graphics Lab/University of Waterloo/Ontario/Canada
More information about the Comp.unix.ultrix
mailing list