-
Notifications
You must be signed in to change notification settings - Fork 1
/
pipestatus_demo
executable file
·68 lines (55 loc) · 984 Bytes
/
pipestatus_demo
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/sh
# by Aleksey Cheusov <vle@gmx.net>
. ./pipestatus
ret1 () {
return 1
}
ret7 () {
return 7
}
ret55 () {
return 55
}
showvars (){
echo '$?'=$?
echo pipesize=$pipesize
echo pipestatus_all=$pipestatus_all
i=1
while test $i -le $pipesize; do
eval echo 'pipestatus_$i=$pipestatus_'$i
i=$(($i+1))
done
}
showrunpipe (){
echo $@ | sed "s/|/'|'/g"
}
run (){
printf "running\n runpipe "
showrunpipe "$@"
runpipe "$@"
showvars
echo ''
}
run0 (){
printf "running\n runpipe0 "
showrunpipe "$@"
runpipe0 "$@"
showvars
echo ''
}
run_re (){
printf "running\n runpipe_re "
re=$1
printf "'%s' " "$re"
shift
showrunpipe "$@"
runpipe_re "$re" "$@"
showvars
echo ''
}
run true '|' true '|' true
run ret1 '|' ret55 '|' ret7
run0 ret1 '|' ret55 '|' true
run0 true '|' true '|' true
run_re '. 0 0' ret1 '|' true '|' true
run_re '0 7 0' true '|' true '|' true