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