Bash-4.3 distribution sources and documentation
[platform/upstream/bash.git] / tests / cprint.tests
1 #
2 # a nonsense script and shell function to test out the command printing code
3 #
4 tf()
5 {
6         # simple command with redir
7         echo this is ${0##*/} > /dev/null
8
9         # pipeline
10         echo a | cat - > /dev/null
11
12         test -f ${0##*/} && echo ${0##*/} is a regular file
13         test -d ${0##*/} || echo ${0##*/} is not a directory
14
15         echo a ; echo b ; echo c
16
17         echo background >/dev/null &
18
19         ( exit 1 )
20         echo $?
21
22         { echo a ; }
23
24         i=0
25         while (( i < 3 )); do
26                 test -r /dev/fd/$i
27                 i=$(( i + 1 ))
28         done
29
30         [[ -r /dev/fd/0 && -w /dev/fd/1 ]] || echo oops > /dev/null
31
32         for name in $( echo 1 2 3 ); do
33                 test -r /dev/fd/$name
34         done
35
36         if [[ -r /dev/fd/0 && -w /dev/fd/1 ]] ; then
37                 echo ok > /dev/null
38         elif (( 7 > 40 )) ; then
39                 echo oops
40         else
41                 echo done
42         fi > /dev/null
43
44         case $PATH in
45         *$PWD*) echo \$PWD in \$PATH ;;
46         *)      echo \$PWD not in \$PATH ;;
47         esac > /dev/null
48
49         while false; do echo z; done > /dev/null
50
51         until true; do echo z ; done > /dev/null
52
53         echo \&\|'()' \{ echo abcde \; \}
54         # when not in POSIX mode, we can have weirdly-named functions
55         eval fu\%nc'()' \{ echo abcde \; \}
56         type fu\%nc
57 }
58
59 tf2()
60 {
61         ( { time -p echo a | cat - > /dev/null ; } ) 2>&1
62 }
63
64 type tf
65 type tf2
66
67 tf