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