summaryrefslogtreecommitdiff
path: root/tests/coproc.tests
blob: 8be3563475f248e6ecf8f7623c0576192fe0bc8c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
coproc { echo a b c; sleep 2; }

echo $COPROC_PID
echo ${COPROC[@]}

read LINE <&${COPROC[0]}
echo $LINE

wait $COPROC_PID

coproc REFLECT { cat - ; }

echo $REFLECT_PID
echo ${REFLECT[@]}

echo flop >&${REFLECT[1]}
read LINE <&${REFLECT[0]}

echo $LINE

kill $REFLECT_PID
wait $REFLECT_PID

coproc xcase -n -u

echo $COPROC_PID
echo ${COPROC[@]}

echo foo >&${COPROC[1]}
read <&${COPROC[0]}

echo $REPLY
echo ${COPROC[@]}

cat /etc/passwd | grep root | awk -F: '{print $1;}' | sed 1q

exec 4<&${COPROC[0]}-
exec >&${COPROC[1]}-

echo ${COPROC[@]}

read foo <&4
echo $foo >&2

exit 0