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