]>
Commit | Line | Data |
---|---|---|
d166f048 | 1 | abc |
8868edaf | 2 | ./redir.tests: line 28: /tmp/redir-test: cannot overwrite existing file |
d166f048 JA |
3 | abc |
4 | def | |
5 | def | |
8868edaf | 6 | ./redir.tests: line 44: $z: ambiguous redirect |
d166f048 JA |
7 | Point 1 |
8 | Point 2 | |
9 | to a | |
10 | to b | |
11 | Point 3 | |
12 | to a | |
13 | to a | |
14 | to b | |
15 | to b | |
16 | Point 4 | |
17 | to c | |
18 | Point 5 | |
19 | this is redir1.sub | |
20 | this is redir2.sub | |
21 | read line1 "ab" | |
22 | read line2 "root" | |
23 | read line3 "cd" | |
24 | read line4 "daemon" | |
25 | from stdin: aa | |
26 | to stdout | |
8868edaf CR |
27 | ./redir4.sub: line 45: $fd: ambiguous redirect |
28 | ./redir4.sub: line 46: $fd: ambiguous redirect | |
d233b485 | 29 | err-and-out: |
d166f048 JA |
30 | to stdout |
31 | to stderr | |
d233b485 | 32 | err-and-out: |
d166f048 JA |
33 | to stdout |
34 | to stderr | |
35 | 0 -- 3 0 | |
36 | 0 -- 4 0 | |
37 | ab | |
38 | cd | |
39 | ef | |
40 | gh | |
41 | ij | |
42 | kl | |
43 | 0 | |
44 | ab | |
45 | cd | |
46 | cd | |
8868edaf CR |
47 | ./redir.tests: line 170: redir1.*: No such file or directory |
48 | # This program is free software: you can redistribute it and/or modify | |
49 | # it under the terms of the GNU General Public License as published by | |
50 | # the Free Software Foundation, either version 3 of the License, or | |
51 | # (at your option) any later version. | |
52 | # | |
53 | # This program is distributed in the hope that it will be useful, | |
54 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
55 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
56 | # GNU General Public License for more details. | |
57 | # | |
58 | # You should have received a copy of the GNU General Public License | |
59 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
60 | # | |
7117c2d2 JA |
61 | # tests of ksh93-like dup-and-close redirection operators |
62 | exec 9<$0 | |
63 | ||
64 | f() | |
65 | { | |
66 | exec 5<$0 | |
67 | ||
68 | exec 0<&5- | |
69 | ||
70 | while read line; do | |
71 | echo "$line" | |
72 | done | |
73 | } | |
74 | ||
75 | f | |
76 | ||
77 | typeset -f f | |
78 | ||
79 | # make sure it was closed | |
d233b485 | 80 | read -u 5 foo 2>&1 | grep -q 'invalid file descriptor' |
7117c2d2 JA |
81 | echo after read |
82 | ||
83 | exec 5<&0 | |
84 | ||
85 | exec <&- | |
86 | ||
d233b485 | 87 | read abcde 2>&1 | grep -q 'read error' |
7117c2d2 JA |
88 | |
89 | exec 0<&9- | |
90 | read line | |
91 | echo $line | |
92 | f () | |
93 | { | |
0628567a | 94 | exec 5< $0; |
7117c2d2 JA |
95 | exec 0<&5-; |
96 | while read line; do | |
97 | echo "$line"; | |
98 | done | |
99 | } | |
7117c2d2 | 100 | after read |
8868edaf | 101 | # This program is free software: you can redistribute it and/or modify |
b80f6443 JA |
102 | / |
103 | / | |
104 | / | |
105 | 0 | |
106 | 0 | |
107 | 0 | |
95732b49 JA |
108 | before block |
109 | after block | |
110 | c1 is 1 | |
111 | c2 is 2 | |
112 | c3 is 3 | |
113 | c4 is 4 | |
3185942a JA |
114 | fd 10 |
115 | fd 8 | |
116 | fd 10 | |
117 | fd 8 | |
118 | 1 | |
119 | 2 | |
120 | 3 | |
121 | 4 | |
122 | 1 | |
123 | 2 | |
124 | 3 | |
125 | 4 | |
126 | cat /tmp/foo | |
127 | whatsis | |
128 | hey | |
129 | to stdout | |
130 | to stderr | |
131 | ||
132 | to stdout | |
133 | to stderr | |
134 | ||
135 | to stderr | |
136 | to stdout | |
137 | ||
138 | to stderr | |
139 | hey | |
140 | to stdout | |
141 | logfunc is a function | |
142 | logfunc () | |
143 | { | |
ac50fbac | 144 | echo "$@" &>> $TMPDIR/log |
3185942a JA |
145 | } |
146 | foo | |
147 | bix is a function | |
148 | bix () | |
149 | { | |
150 | echo foo 2>&1 | cat | |
151 | } | |
152 | foo | |
ac50fbac | 153 | :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: |
a0c0a00f | 154 | 1 |
a0c0a00f CR |
155 | 7 |
156 | after: 42 | |
8868edaf | 157 | ./redir11.sub: line 53: $(ss= declare -i ss): ambiguous redirect |
a0c0a00f CR |
158 | after: 42 |
159 | a+=3 | |
160 | foo | |
161 | foo | |
8868edaf CR |
162 | ./redir11.sub: line 75: 42: No such file or directory |
163 | 42 |