]> git.saurik.com Git - apple/shell_cmds.git/blob - sh/tests/execution/redir1.0
shell_cmds-216.60.1.tar.gz
[apple/shell_cmds.git] / sh / tests / execution / redir1.0
1 # $FreeBSD: head/bin/sh/tests/execution/redir1.0 211408 2010-08-16 22:23:19Z jilles $
2 trap ': $((brokenpipe+=1))' PIPE
3
4 P=${TMPDIR:-/tmp}
5 cd $P
6 T=$(mktemp -d sh-test.XXXXXX)
7 cd $T
8
9 brokenpipe=0
10 mkfifo fifo1 fifo2
11 read dummy >fifo2 <fifo1 &
12 {
13 exec 4>fifo2
14 } 3<fifo2 # Formerly, sh would keep fd 3 and a duplicate of it open.
15 echo dummy >fifo1
16 if [ $brokenpipe -ne 0 ]; then
17 rc=3
18 fi
19 wait
20 echo dummy >&4 2>/dev/null
21 if [ $brokenpipe -eq 1 ]; then
22 : ${rc:=0}
23 fi
24
25 rm fifo1 fifo2
26 rmdir ${P}/${T}
27 exit ${rc:-3}