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#
15# Test that redirections attached to shell functions are printed correctly.
16# This was a bug in all bash versions before bash-2.04.
17#
18f()
19{
20	echo f-x
21	echo f-y
22} >&2
23
24type f
25export -f f
26${THIS_SH} -c 'echo subshell; type f'
27
28f2()
29{
30	echo f2-a
31	f3()
32	{
33		echo f3-a
34		echo f3-b
35	} >&2
36	f3
37}
38
39type f2
40
41export -f f2
42${THIS_SH} -c 'echo subshell; type f2'
43
44f4()
45{
46	echo f4-a
47	f5()
48	{
49		echo f5-a
50		echo f5-b
51	} >&2
52	f5
53} 2>&1
54
55type f4
56export -f f4
57${THIS_SH} -c 'echo subshell; type f4'
58
59testgrp()
60{
61	echo testgrp-a
62	{ echo tg-x; echo tg-y; } >&2
63	echo testgrp-b
64}
65type testgrp
66
67export -f testgrp
68${THIS_SH} -c 'echo subshell; type testgrp'
69