]> git.ipfire.org Git - thirdparty/bash.git/blob - tests/posix2syntax.sub
Bash-5.2 patch 32: fix printing coprocs when the coproc does not have a name
[thirdparty/bash.git] / tests / posix2syntax.sub
1 # This program is free software: you can redistribute it and/or modify
2 # it under the terms of the GNU General Public License as published by
3 # the Free Software Foundation, either version 3 of the License, or
4 # (at your option) any later version.
5 #
6 # This program is distributed in the hope that it will be useful,
7 # but WITHOUT ANY WARRANTY; without even the implied warranty of
8 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 # GNU General Public License for more details.
10 #
11 # You should have received a copy of the GNU General Public License
12 # along with this program. If not, see <http://www.gnu.org/licenses/>.
13 #
14 : ${THIS_SH:=./bash}
15 bashname=bash${BASH_VERSION%%.*}
16
17 # tests for Posix grammar special cases
18
19 # Posix grammar rule 5
20 ${THIS_SH} -c 'for invalid-name in a b c; do echo error; done' $bashname
21
22 # Posix grammar rule 6: third word in FOR or SELECT
23 for i; do echo; done; echo in
24 for i; do echo in; done
25 for i do echo in; done
26
27 select i; do echo; done; echo in
28 select i; do echo in; done; echo in
29 select i do echo in; done; echo in
30
31 # Posix grammar rule 4: when PATTERN == ESAC, return ESAC
32 ${THIS_SH} -c 'case x in esac) echo done; esac' $bashname
33
34 # Posix grammar rule 6: third word in CASE
35 ${THIS_SH} -c 'case in in in) echo in; esac;' $bashname
36 ${THIS_SH} -c 'case in do do) echo in; esac' $bashname
37
38 # Posix grammar rule 8: function NAME
39 ${THIS_SH} -o posix -c 'for()
40 {
41 echo function for;
42 }' $bashname
43
44 for for in for; do echo in; echo done; done
45
46 ${THIS_SH} -c 'for (( i = 0; i < 5; i++ )) do : ; done' $bashname
47 ${THIS_SH} -c 'for (( i = 0; i < 5; i++ )) { : ; }' $bashname
48
49 # bug report: IN turning on unwanted alias expansion
50 ${THIS_SH} -o posix -c '
51 alias foo='two words'
52 foo_word='foo'
53 case "$foo_word"
54 in
55 foo) echo "bad 1";;
56 esac' $bashname
57
58 ${THIS_SH} -o posix -c '
59 alias foo='oneword'
60 foo_word='foo'
61 case "$foo_word"
62 in
63 foo) echo "ok 1";;
64 esac' $bashname
65
66