]>
Commit | Line | Data |
---|---|---|
8868edaf CR |
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 | # | |
cce855bc JA |
14 | export LC_ALL=C |
15 | export LANG=C | |
16 | ||
17 | # test out the new $(< filename) code | |
18 | # it should be exactly equivalent to $(cat filename) | |
19 | ||
d233b485 | 20 | FILENAME=$TMPDIR/bashtmp.x$$ |
cce855bc JA |
21 | |
22 | trap 'rm -f $FILENAME' 0 | |
23 | ||
24 | cat >$FILENAME << EOF | |
25 | line 1 | |
26 | line 2 | |
27 | line 3 | |
28 | EOF | |
29 | ||
30 | LINES1=$(cat $FILENAME) | |
31 | LINES2=$(< $FILENAME) | |
32 | ||
33 | if [[ $LINES1 != $LINES2 ]]; then | |
34 | echo 'whoops: $(< filename) failed' | |
35 | fi | |
36 | ||
d233b485 | 37 | LINES2=$(< $TMPDIR/bashtmp.x*) |
cce855bc JA |
38 | if [[ $LINES1 != $LINES2 ]]; then |
39 | echo 'whoops: $(< filename) with glob expansion failed' | |
40 | fi | |
41 | ||
42 | # but the glob expansion in the redirection should fail in posix mode | |
43 | set -o posix | |
d233b485 CR |
44 | exec 3>&2 |
45 | exec 2>/dev/null | |
46 | LINES2=$(< $TMPDIR/bashtmp.x*) | |
47 | exec 2>&3 | |
48 | if [[ $LINES2 -gt 0 ]]; then | |
49 | echo "whoops: redirection glob expansion should be disabled in posix mode" >&2 | |
50 | fi | |
cce855bc JA |
51 | set +o posix |
52 | ||
8868edaf | 53 | # now see what happens when we try it with a non-existent file |
d233b485 | 54 | rm -f /tmp/redir-notthere |
cce855bc JA |
55 | LINES3=$(< /tmp/redir-notthere) |
56 | echo $? | |
ac50fbac CR |
57 | |
58 | # These were bugs through bash-4.2 | |
59 | { : "$({xxxxxxxxxxxxxxxxxxxx}</dev/stdin)"; } <<<'hi' | |
60 | echo ${xxxxxxxxxxxxxxxxxxxx} | |
61 | ||
62 | { echo "$(1111111111111111111111</dev/stdin)"; } <<<'hi' |