Imported from ../bash-2.05.tar.gz.
[platform/upstream/bash.git] / tests / func1.sub
1 #
2 # Test that redirections attached to shell functions are printed correctly.
3 # This was a bug in all bash versions before bash-2.04.
4 #
5 f()
6 {
7         echo f-x
8         echo f-y
9 } >&2
10
11 type f
12 export -f f
13 ${THIS_SH} -c 'echo subshell; type f'
14
15 f2()
16 {
17         echo f2-a
18         f3()
19         {
20                 echo f3-a
21                 echo f3-b
22         } >&2
23         f3
24 }
25
26 type f2
27
28 export -f f2
29 ${THIS_SH} -c 'echo subshell; type f2'
30
31 f4()
32 {
33         echo f4-a
34         f5()
35         {
36                 echo f5-a
37                 echo f5-b
38         } >&2
39         f5
40 } 2>&1
41
42 type f4
43 export -f f4
44 ${THIS_SH} -c 'echo subshell; type f4'
45
46 testgrp()
47 {
48         echo testgrp-a
49         { echo tg-x; echo tg-y; } >&2
50         echo testgrp-b
51 }
52 type testgrp
53
54 export -f testgrp
55 ${THIS_SH} -c 'echo subshell; type testgrp'