Line | |
---|
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 |
|
---|
7 | FILENAME=/tmp/bashtmp.x$$
|
---|
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 |
|
---|
24 | LINES2=$(< /tmp/bashtmp.x*)
|
---|
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
|
---|
31 | LINES2=$(< /tmp/bashtmp.x*)
|
---|
32 | set +o posix
|
---|
33 |
|
---|
34 | # now see what happens when we try it with a non-existant file
|
---|
35 | LINES3=$(< /tmp/redir-notthere)
|
---|
36 | echo $?
|
---|
Note:
See
TracBrowser
for help on using the repository browser.