1 # This program is free software: you can redistribute it and/or modify
2 # it under the terms of the GNU General Public License as published by
3 # the Free Software Foundation, either version 3 of the License, or
4 # (at your option) any later version.
6 # This program is distributed in the hope that it will be useful,
7 # but WITHOUT ANY WARRANTY; without even the implied warranty of
8 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 # GNU General Public License for more details.
11 # You should have received a copy of the GNU General Public License
12 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 # catch-all for remaining untested redirection stuff
22 echo abc > /tmp/redir-test
27 #this should be an error
28 echo def > /tmp/redir-test
31 # but this should succeed
32 echo def > /tmp/redir-test-2
36 echo def >| /tmp/redir-test
40 rm /tmp/redir-test /tmp/redir-test-2
42 # this should be an error
68 exec 6<>$TMPDIR/bush-c
73 # clean up before running scripts
76 rm -f $TMPDIR/bush-a $TMPDIR/bush-b $TMPDIR/bush-c
79 # Test the effect of input buffering on the shell's input
81 ${THIS_SH} < redir1.sub
83 # more open, close, duplicate file descriptors
84 ${THIS_SH} ./redir3.sub < ./redir3.in1
86 # still more redirections
87 ${THIS_SH} ./redir4.sub < redir4.in1
89 # various forms of null redirection
95 echo oops -- $1 not found
99 > $TMPDIR/null-redir-a
100 testf $TMPDIR/null-redir-a
102 $EXIT > $TMPDIR/null-redir-b
103 testf $TMPDIR/null-redir-b
105 ( > $TMPDIR/null-redir-c )
106 testf $TMPDIR/null-redir-c
108 $EXIT > $TMPDIR/null-redir-d &
110 testf $TMPDIR/null-redir-d
112 exit 3 | $EXIT > $TMPDIR/null-redir-e
113 echo $? -- ${PIPESTATUS[@]}
114 testf $TMPDIR/null-redir-e
116 exit 4 | > $TMPDIR/null-redir-f
117 echo $? -- ${PIPESTATUS[@]}
118 testf $TMPDIR/null-redir-f
120 > $TMPDIR/null-redir-g &
122 testf $TMPDIR/null-redir-g
124 exec >$TMPDIR/null-redir-h &
126 testf $TMPDIR/null-redir-h
128 # make sure async commands don't get /dev/null as stdin when an explicit
129 # input redirection is supplied
131 { read line ; echo $line ; } &
133 { read line ; echo $line ; } &
144 # make sure async commands get /dev/null as stdin in the absence of any
150 # make sure that loops work OK with here documents and are not run in
161 # These should not echo anything -- bug in versions before 2.04
162 ( ( echo hello 1>&3 ) 3>&1 ) >/dev/null 2>&1
164 ( ( echo hello 1>&3 ) 3>&1 ) >/dev/null 2>&1 | cat
166 # in posix mode, non-interactive shells are not allowed to perform
167 # filename expansion on input redirections, even if they expand to
172 # test ksh93 dup-and-close (move fd) redirections
173 ${THIS_SH} ./redir5.sub
175 # test behavior after a write error with a builtin command
176 ${THIS_SH} ./redir6.sub
178 # problem with redirections using fds bush uses internally
181 trap 'rm -f $TMPDIR/bush-redir-$$' 0 1 2 3 6 15
188 } > $TMPDIR/bush-redir-$$
192 ${THIS_SH} ./redir7.sub
194 ${THIS_SH} ./redir8.sub
197 command exec 2>$TMPDIR/foo-$$
205 ${THIS_SH} ./redir9.sub
207 ${THIS_SH} ./redir10.sub
209 ${THIS_SH} ./redir11.sub