1echo T.redir: test redirections 2 3awk=${awk-../a.out} 4 5$awk '{ print >"foo" }' /etc/passwd 6diff foo /etc/passwd || echo 'BAD: T.redir (print >"foo")' 7 8rm -f foo 9$awk '{ print >>"foo" }' /etc/passwd 10diff foo /etc/passwd || echo 'BAD: T.redir (print >>"foo")' 11 12rm -f foo 13$awk 'NR%2 == 1 { print >>"foo" } 14 NR%2 == 0 { print >"foo" }' /etc/passwd 15diff foo /etc/passwd || echo 'BAD: T.redir (print > and >>"foo")' 16 17rm -f foo 18$awk '{ print | "cat >foo" }' /etc/passwd 19diff foo /etc/passwd || echo 'BAD: T.redir (print | "cat >foo")' 20 21# tests flush of stdout before opening pipe 22echo ' head 231 242' >foo1 25$awk 'BEGIN { print " head" 26 for (i = 1; i < 3; i++) 27 print i | "sort" }' >foo2 28diff foo1 foo2 || echo 'BAD: T.redir (buffering)' 29 30rm -f foo[12] 31$awk '{ print >"/dev/stderr" }' /etc/passwd 1>foo1 2>foo2 32diff foo2 /etc/passwd || echo 'BAD: T.redir (print >"/dev/stderr")' 33diff foo1 /dev/null || echo 'BAD: T.redir (print >"/dev/stderr")' 34 35rm -f foo[12] 36$awk '{ print >"/dev/stdout" }' /etc/passwd 1>foo1 2>foo2 37diff foo1 /etc/passwd || echo 'BAD: T.redir (print >"/dev/stdout")' 38diff foo2 /dev/null || echo 'BAD: T.redir (print >"/dev/stderr")' 39