]>
Commit | Line | Data |
---|---|---|
495aee44 CR |
1 | binfalse() |
2 | { | |
3 | $binfalse || return 1 # normalize return value | |
4 | } | |
5 | ||
6 | if [ -x /usr/bin/true ]; then | |
7 | bintrue=/usr/bin/true | |
8 | elif [ -x /bin/true ]; then | |
9 | bintrue=/bin/true | |
10 | else | |
11 | bintrue=true | |
12 | fi | |
13 | if [ -x /usr/bin/false ]; then | |
14 | binfalse=/usr/bin/false | |
15 | elif [ -x /bin/false ]; then | |
16 | binfalse=/bin/false | |
17 | else | |
18 | binfalse=true | |
19 | fi | |
20 | ||
21 | shopt -s lastpipe | |
22 | ||
23 | unset foo bar | |
24 | echo a b c | read foo | |
25 | echo after 1: foo = $foo | |
26 | ||
27 | unset tot | |
28 | declare -i tot | |
29 | printf "%d\n" 1 2 3 | while read foo; do tot+=$foo; done | |
30 | echo after 2: tot = $tot | |
31 | ||
32 | unset bar | |
33 | echo g h i | bar=7 | |
34 | echo after: $bar | |
35 | ||
36 | unset foo last | |
37 | printf "%s\n" a b c | while read foo; do last=$foo; done | |
38 | echo last = $last | |
39 | ||
40 | exit 142 | false | |
41 | echo $? -- ${PIPESTATUS[@]} | |
42 | ||
43 | true | false | $bintrue | |
44 | echo $? -- ${PIPESTATUS[@]} | |
45 | ||
46 | true | $bintrue | false | |
47 | echo $? -- ${PIPESTATUS[@]} | |
48 | ||
49 | set -o pipefail | |
50 | true | $bintrue | false | |
51 | echo $? -- ${PIPESTATUS[@]} | |
52 | ||
53 | true | binfalse | true | |
54 | echo $? -- ${PIPESTATUS[@]} | |
55 | set +o pipefail | |
56 | ||
57 | ${THIS_SH} ./lastpipe1.sub | |
58 | echo lastpipe1.sub returns $? |