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