Added gitignore entries needed to ignore derived objects generated from full build...
[bash.git] / tests / lastpipe.tests
blob13fa214ffb0fa4ae39a480345d298be511e81a6c
1 binfalse()
3         $binfalse || return 1   # normalize return value
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
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
21 shopt -s lastpipe
23 unset foo bar
24 echo a b c | read foo
25 echo after 1: foo = $foo
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
32 unset bar
33 echo g h i | bar=7
34 echo after: $bar
36 unset foo last
37 printf "%s\n" a b c | while read foo; do last=$foo; done
38 echo last = $last
40 exit 142 | false
41 echo $? -- ${PIPESTATUS[@]}
43 true | false | $bintrue
44 echo $? -- ${PIPESTATUS[@]}
46 true | $bintrue | false
47 echo $? -- ${PIPESTATUS[@]}
49 set -o pipefail
50 true | $bintrue | false
51 echo $? -- ${PIPESTATUS[@]}
53 true | binfalse | true
54 echo $? -- ${PIPESTATUS[@]}
55 set +o pipefail
57 ${THIS_SH} ./lastpipe1.sub
58 echo lastpipe1.sub returns $?