1echo T.close: test close built-in 2 3awk=${awk-../a.out} 4 5rm -f foo 6$awk '{ print >>"foo"; close("foo") }' /etc/passwd 7diff /etc/passwd foo || echo 'BAD: T.close (1)' 8 9ls -l >foo 10tail -1 foo >foo1 11$awk '{ print >"foo2"; close("foo2") }' foo 12diff foo1 foo2 || echo 'BAD: T.close (2)' 13 14echo 0 >foo1 15$awk ' # non-accessible file 16 BEGIN { getline <"/etc/passwd"; print close("/etc/passwd"); } 17' >foo2 18diff foo1 foo2 || echo 'BAD: T.close (3)' 19 20echo -1 >foo1 21$awk ' # file not opened 22 BEGIN { print close("glotch"); } 23' >foo2 24diff foo1 foo2 || echo 'BAD: T.close (4)' 25 26echo 0 >foo1 27$awk ' # normal close 28 BEGIN { print "hello" > "foo"; print close("foo"); } 29' >foo2 30diff foo1 foo2 || echo 'BAD: T.close (5)' 31 32echo 0 >foo1 33$awk ' # normal close 34 BEGIN { print "hello" | "cat >foo"; print close("cat >foo"); } 35' >foo2 36diff foo1 foo2 || echo 'BAD: T.close (6)' 37