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