commit bash-20080522 snapshot

This commit is contained in:
Chet Ramey
2011-12-07 09:24:08 -05:00
parent 33fe8777ce
commit 8943768b87
74 changed files with 3052 additions and 462 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
BUILD_DIR=/usr/local/build/chet/bash/bash-current
BUILD_DIR=/usr/local/build/bash/bash-current
THIS_SH=$BUILD_DIR/bash
PATH=$PATH:$BUILD_DIR
+28
View File
@@ -43,3 +43,31 @@ f
-20 -19 -18 -17 -16 -15 -14 -13 -12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0
a-{bd}-c a-{be}-c
a-{bdef-g-c a-{bdef-i-c
{klklkl}1 {klklkl}2 {klklkl}3
{x,x}
1 3 5 7 9
-1 -3 -5 -7 -9
-1 -3 -5 -7 -9
10 8 6 4 2
10 8 6 4 2
1 3 5 7 9 11 13 15 17 19
1
0100 0095 0090 0085 0080 0075 0070 0065 0060 0055 0050 0045 0040 0035 0030 0025 0020 0015 0010 0005 0000
00100 00095 00090 00085 00080 00075 00070 00065 00060 00055 00050 00045 00040 00035 00030 00025 00020 00015 00010 00005 00000
a b c d e f g h i j k l m n o p q r s t u v w x y z
a c e g i k m o q s u w y
z x v t r p n l j h f d b
{1..10.f}
{1..ff}
{1..10..ff}
{1.20..2}
{1..20..f2}
{1..20..2f}
{1..2f..2}
{1..ff..2}
{1..ff}
{1..f}
{1..0f}
{1..10f}
{1..10.f}
{1..10.f}
+36
View File
@@ -73,3 +73,39 @@ echo {-20..0}
echo a-{b{d,e}}-c
echo a-{bdef-{g,i}-c
echo {"klklkl"}{1,2,3}
echo {"x,x"}
echo {1..10..2}
echo {-1..-10..2}
echo {-1..-10..-2}
echo {10..1..-2}
echo {10..1..2}
echo {1..20..2}
echo {1..20..20}
echo {100..0..5}
echo {100..0..-5}
echo {a..z}
echo {a..z..2}
echo {z..a..-2}
# bad
echo {1..10.f}
echo {1..ff}
echo {1..10..ff}
echo {1.20..2}
echo {1..20..f2}
echo {1..20..2f}
echo {1..2f..2}
echo {1..ff..2}
echo {1..ff}
echo {1..f}
echo {1..0f}
echo {1..10f}
echo {1..10.f}
echo {1..10.f}
+78
View File
@@ -0,0 +1,78 @@
echo ff{c,b,a}
echo f{d,e,f}g
echo {l,n,m}xyz
echo {abc\,def}
echo {abc}
echo \{a,b,c,d,e}
echo {x,y,\{a,b,c}}
echo {x\,y,\{abc\},trie}
echo /usr/{ucb/{ex,edit},lib/{ex,how_ex}}
echo XXXX\{`echo a b c | tr ' ' ','`\}
eval echo XXXX\{`echo a b c | tr ' ' ','`\}
echo {}
echo { }
echo }
echo {
echo abcd{efgh
echo foo {1,2} bar
echo `zecho foo {1,2} bar`
echo $(zecho foo {1,2} bar)
var=baz
varx=vx
vary=vy
echo foo{bar,${var}.}
echo foo{bar,${var}}
echo "${var}"{x,y}
echo $var{x,y}
echo ${var}{x,y}
unset var varx vary
# new sequence brace operators
echo {1..10}
# this doesn't work yet
echo {0..10,braces}
# but this does
echo {{0..10},braces}
echo x{{0..10},braces}y
echo {3..3}
echo x{3..3}y
echo {10..1}
echo {10..1}y
echo x{10..1}y
echo {a..f}
echo {f..a}
echo {a..A}
echo {A..a}
echo {f..f}
# mixes are incorrectly-formed brace expansions
echo {1..f}
echo {f..1}
echo 0{1..9} {10..20}
# do negative numbers work?
echo {-1..-10}
echo {-20..0}
# weirdly-formed brace expansions -- fixed in post-bash-3.1
echo a-{b{d,e}}-c
echo a-{bdef-{g,i}-c
echo {"klklkl"}{1,2,3}
echo {"x,x"}
+5
View File
@@ -0,0 +1,5 @@
fallthrough
to here
and here
retest
and match
+14
View File
@@ -0,0 +1,14 @@
case foo in
bar) echo skip ;;
foo) echo fallthrough ;&
bax) echo to here ;&
qux) echo and here;;
fop) echo but not here;;
esac
case foobar in
bar) echo skip ;;
foo*) echo retest ;;&
*bar) echo and match ;;&
qux) echo but not this ;;
esac
+1
View File
@@ -34,6 +34,7 @@ returns: 1
returns: 0
ok
jbig2dec
found 1
libc
found 2
+4
View File
@@ -158,6 +158,10 @@ fi
[[ jbig2dec-0.9-i586-001.tgz =~ ([^-]+)-([^-]+)-([^-]+)-0*([1-9][0-9]*)\.tgz ]]
echo ${BASH_REMATCH[1]}
# this shouldn't echo anything
[[ jbig2dec-0.9-i586-001.tgz =~ \([^-]+\)-\([^-]+\)-\([^-]+\)-0*\([1-9][0-9]*\)\.tgz ]]
echo ${BASH_REMATCH[1]}
LDD_BASH=" linux-gate.so.1 => (0xffffe000)
libreadline.so.5 => /lib/libreadline.so.5 (0xb7f91000)
libhistory.so.5 => /lib/libhistory.so.5 (0xb7f8a000)
+16
View File
@@ -158,6 +158,22 @@ fi
[[ jbig2dec-0.9-i586-001.tgz =~ ([^-]+)-([^-]+)-([^-]+)-0*([1-9][0-9]*)\.tgz ]]
echo ${BASH_REMATCH[1]}
LDD_BASH=" linux-gate.so.1 => (0xffffe000)
libreadline.so.5 => /lib/libreadline.so.5 (0xb7f91000)
libhistory.so.5 => /lib/libhistory.so.5 (0xb7f8a000)
libncurses.so.5 => /lib/libncurses.so.5 (0xb7f55000)
libdl.so.2 => /lib/libdl.so.2 (0xb7f51000)
libc.so.6 => /lib/libc.so.6 (0xb7e34000)
/lib/ld-linux.so.2 (0xb7fd0000)"
[[ "$LDD_BASH" =~ "libc" ]] && echo "found 1"
echo ${BASH_REMATCH[@]}
[[ "$LDD_BASH" =~ libc ]] && echo "found 2"
echo ${BASH_REMATCH[@]}
# bug in all versions up to and including bash-2.05b
if [[ "123abc" == *?(a)bc ]]; then echo ok 42; else echo bad 42; fi
if [[ "123abc" == *?(a)bc ]]; then echo ok 43; else echo bad 43; fi
${THIS_SH} ./cond-regexp.sub
+28 -3
View File
@@ -1,9 +1,9 @@
abc
./redir.tests: line 13: /tmp/redir-test: cannot overwrite existing file
./redir.tests: line 15: /tmp/redir-test: cannot overwrite existing file
abc
def
def
./redir.tests: line 29: $z: ambiguous redirect
./redir.tests: line 31: $z: ambiguous redirect
Point 1
Point 2
to a
@@ -44,7 +44,7 @@ kl
ab
cd
cd
./redir.tests: line 152: redir1.*: No such file or directory
./redir.tests: line 154: redir1.*: No such file or directory
# tests of ksh93-like dup-and-close redirection operators
exec 9<$0
@@ -114,3 +114,28 @@ fd 8
4
cat /tmp/foo
whatsis
hey
to stdout
to stderr
to stdout
to stderr
to stderr
to stdout
to stderr
hey
to stdout
logfunc is a function
logfunc ()
{
echo "$@" &>>$TMPDIR/log
}
foo
bix is a function
bix ()
{
echo foo 2>&1 | cat
}
foo
+33 -29
View File
@@ -1,3 +1,5 @@
: ${TMPDIR:=/tmp}
export LC_ALL=C
export LANG=C
@@ -31,31 +33,31 @@ cat < $z
echo "Point 1"
exec 3</etc/passwd
exec 4>/tmp/bash-a
exec 5>/tmp/bash-b
exec 4>$TMPDIR/bash-a
exec 5>$TMPDIR/bash-b
echo "Point 2"
echo to a 1>&4
echo to b 1>&5
cat /tmp/bash-a
cat /tmp/bash-b
cat $TMPDIR/bash-a
cat $TMPDIR/bash-b
exec 11</dev/null
echo "Point 3"
echo to a 1>&4
echo to b 1>&5
cat /tmp/bash-a
cat /tmp/bash-b
cat $TMPDIR/bash-a
cat $TMPDIR/bash-b
exec 11<&-
echo "Point 4"
exec 6<>/tmp/bash-c
exec 6<>$TMPDIR/bash-c
echo to c 1>&6
cat /tmp/bash-c
cat $TMPDIR/bash-c
echo "Point 5"
rm -f /tmp/bash-a /tmp/bash-b /tmp/bash-c
rm -f $TMPDIR/bash-a $TMPDIR/bash-b $TMPDIR/bash-c
#
# Test the effect of input buffering on the shell's input
@@ -78,34 +80,34 @@ testf()
fi
}
> /tmp/null-redir-a
testf /tmp/null-redir-a
> $TMPDIR/null-redir-a
testf $TMPDIR/null-redir-a
$EXIT > /tmp/null-redir-b
testf /tmp/null-redir-b
$EXIT > $TMPDIR/null-redir-b
testf $TMPDIR/null-redir-b
( > /tmp/null-redir-c )
testf /tmp/null-redir-c
( > $TMPDIR/null-redir-c )
testf $TMPDIR/null-redir-c
$EXIT > /tmp/null-redir-d &
$EXIT > $TMPDIR/null-redir-d &
wait
testf /tmp/null-redir-d
testf $TMPDIR/null-redir-d
exit 3 | $EXIT > /tmp/null-redir-e
exit 3 | $EXIT > $TMPDIR/null-redir-e
echo $? -- ${PIPESTATUS[@]}
testf /tmp/null-redir-e
testf $TMPDIR/null-redir-e
exit 4 | > /tmp/null-redir-f
exit 4 | > $TMPDIR/null-redir-f
echo $? -- ${PIPESTATUS[@]}
testf /tmp/null-redir-f
testf $TMPDIR/null-redir-f
> /tmp/null-redir-g &
> $TMPDIR/null-redir-g &
wait
testf /tmp/null-redir-g
testf $TMPDIR/null-redir-g
exec >/tmp/null-redir-h &
exec >$TMPDIR/null-redir-h &
wait
testf /tmp/null-redir-h
testf $TMPDIR/null-redir-h
# make sure async commands don't get /dev/null as stdin when an explicit
# input redirection is supplied
@@ -158,7 +160,7 @@ ${THIS_SH} ./redir5.sub
${THIS_SH} ./redir6.sub
# problem with redirections using fds bash uses internally
: ${TMPDIR:=/tmp}
: ${TMPDIR:=$TMPDIR}
trap 'rm -f $TMPDIR/bash-redir-$$' 0 1 2 3 6 15
@@ -176,10 +178,12 @@ ${THIS_SH} ./redir7.sub
${THIS_SH} ./redir8.sub
exec 9>&2
command exec 2>/tmp/foo
command exec 2>$TMPDIR/foo
echo whatsis >&2
echo cat /tmp/foo
cat /tmp/foo
rm -f /tmp/foo
cat $TMPDIR/foo
rm -f $TMPDIR/foo
exec 2>&9
exec 9>&-
${THIS_SH} ./redir9.sub
+39 -26
View File
@@ -1,3 +1,5 @@
: ${TMPDIR:=/tmp}
export LC_ALL=C
export LANG=C
@@ -31,31 +33,31 @@ cat < $z
echo "Point 1"
exec 3</etc/passwd
exec 4>/tmp/bash-a
exec 5>/tmp/bash-b
exec 4>$TMPDIR/bash-a
exec 5>$TMPDIR/bash-b
echo "Point 2"
echo to a 1>&4
echo to b 1>&5
cat /tmp/bash-a
cat /tmp/bash-b
cat $TMPDIR/bash-a
cat $TMPDIR/bash-b
exec 11</dev/null
echo "Point 3"
echo to a 1>&4
echo to b 1>&5
cat /tmp/bash-a
cat /tmp/bash-b
cat $TMPDIR/bash-a
cat $TMPDIR/bash-b
exec 11<&-
echo "Point 4"
exec 6<>/tmp/bash-c
exec 6<>$TMPDIR/bash-c
echo to c 1>&6
cat /tmp/bash-c
cat $TMPDIR/bash-c
echo "Point 5"
rm -f /tmp/bash-a /tmp/bash-b /tmp/bash-c
rm -f $TMPDIR/bash-a $TMPDIR/bash-b $TMPDIR/bash-c
#
# Test the effect of input buffering on the shell's input
@@ -78,34 +80,34 @@ testf()
fi
}
> /tmp/null-redir-a
testf /tmp/null-redir-a
> $TMPDIR/null-redir-a
testf $TMPDIR/null-redir-a
$EXIT > /tmp/null-redir-b
testf /tmp/null-redir-b
$EXIT > $TMPDIR/null-redir-b
testf $TMPDIR/null-redir-b
( > /tmp/null-redir-c )
testf /tmp/null-redir-c
( > $TMPDIR/null-redir-c )
testf $TMPDIR/null-redir-c
$EXIT > /tmp/null-redir-d &
$EXIT > $TMPDIR/null-redir-d &
wait
testf /tmp/null-redir-d
testf $TMPDIR/null-redir-d
exit 3 | $EXIT > /tmp/null-redir-e
exit 3 | $EXIT > $TMPDIR/null-redir-e
echo $? -- ${PIPESTATUS[@]}
testf /tmp/null-redir-e
testf $TMPDIR/null-redir-e
exit 4 | > /tmp/null-redir-f
exit 4 | > $TMPDIR/null-redir-f
echo $? -- ${PIPESTATUS[@]}
testf /tmp/null-redir-f
testf $TMPDIR/null-redir-f
> /tmp/null-redir-g &
> $TMPDIR/null-redir-g &
wait
testf /tmp/null-redir-g
testf $TMPDIR/null-redir-g
exec >/tmp/null-redir-h &
exec >$TMPDIR/null-redir-h &
wait
testf /tmp/null-redir-h
testf $TMPDIR/null-redir-h
# make sure async commands don't get /dev/null as stdin when an explicit
# input redirection is supplied
@@ -158,7 +160,7 @@ ${THIS_SH} ./redir5.sub
${THIS_SH} ./redir6.sub
# problem with redirections using fds bash uses internally
: ${TMPDIR:=/tmp}
: ${TMPDIR:=$TMPDIR}
trap 'rm -f $TMPDIR/bash-redir-$$' 0 1 2 3 6 15
@@ -174,3 +176,14 @@ echo after block
${THIS_SH} ./redir7.sub
${THIS_SH} ./redir8.sub
exec 9>&2
command exec 2>$TMPDIR/foo
echo whatsis >&2
echo cat $TMPDIR/foo
cat $TMPDIR/foo
rm -f $TMPDIR/foo
exec 2>&9
exec 9>&-
${THIS_SH} ./redir9.sub
-3
View File
@@ -55,6 +55,3 @@ exec 0<&7
exec 7<&-
exit 0
+60
View File
@@ -0,0 +1,60 @@
rm -f u
${THIS_SH} -c 'exec 10>&1; echo fd 10 >&10' 10>u
cat u
rm -f u
${THIS_SH} -c 'exec 8>&1; echo fd 8 >&8' 8>u
cat u
rm -f u
exec 10>u
exec 10>&1; echo 'fd 10' >&10
cat u
rm -f u
exec 10>&-
exec 8>u
exec 8>&1; echo 'fd 8' >&8
cat u
rm -f u
exec 8>&-
rm -f infile
cat > infile <<EOF
1
2
3
4
EOF
exec 7<&0
exec 10<infile
exec 0<&10; cat <&10
exec 0<&7
exec 7<&-
exec 7<&0
exec 8<infile
exec 0<&8 ; cat <&8
exec 0<&7
exec 7<&-
exec 7<&0
exec 0</dev/null
exec 10<infile
exec 10<&0; cat <&10
exec 0<&7
exec 7<&-
exec 7<&0
exec 0</dev/null
exec 8<infile
exec 8<&0; cat <&8
exec 0<&7
exec 7<&-
exit 0
+48
View File
@@ -0,0 +1,48 @@
: ${TMPDIR:=/tmp}
func()
{
echo "to stdout"
echo "to stderr" >&2
}
rm -f $TMPDIR/foo
echo hey > $TMPDIR/foo
func &>> $TMPDIR/foo
cat $TMPDIR/foo
echo
func &> $TMPDIR/foo
cat $TMPDIR/foo
echo
func >$TMPDIR/foo
cat $TMPDIR/foo
echo
echo hey > $TMPDIR/foo
func >> $TMPDIR/foo
cat $TMPDIR/foo
rm -f $TMPDIR/foo
logfunc()
{
echo "$@" &>> $TMPDIR/log
}
type logfunc
echo foo 2>&1
bix()
{
echo foo |& cat
}
type bix
bix
+37
View File
@@ -0,0 +1,37 @@
: ${TMPDIR:=/tmp}
func()
{
echo "to stdout"
echo "to stderr" >&2
}
rm -f $TMPDIR/foo
echo hey > $TMPDIR/foo
func &>> $TMPDIR/foo
cat $TMPDIR/foo
echo
func &> $TMPDIR/foo
cat $TMPDIR/foo
echo
func >$TMPDIR/foo
cat $TMPDIR/foo
echo
echo hey > $TMPDIR/foo
func >> $TMPDIR/foo
cat $TMPDIR/foo
rm -f $TMPDIR/foo
logfunc()
{
echo "$@" &>> $TMPDIR/log
}
type logfunc
+2
View File
@@ -0,0 +1,2 @@
${THIS_SH} ./case.tests > /tmp/xx 2>&1
diff /tmp/xx case.right && rm -f /tmp/xx
+6
View File
@@ -0,0 +1,6 @@
echo "warning: all of these tests will fail if arrays have not" >&2
echo "warning: been compiled into the shell" >&2
echo "warning: the BASH_ARGC and BASH_ARGV tests will fail if debugging support" >&2
echo "warning: has not been compiled into the shell" >&2
${THIS_SH} ./array.tests > /tmp/xx 2>&1
diff /tmp/xx array.right && rm -f /tmp/xx
+10
View File
@@ -51,3 +51,13 @@ f ()
{
v='^A'
}
foo is a function
foo ()
{
echo $(<x1)
}
bar is a function
bar ()
{
echo $(<x1)
}
+2
View File
@@ -87,3 +87,5 @@ f() {
}
type f | cat -v
${THIS_SH} type1.sub
+7
View File
@@ -80,3 +80,10 @@ type -t $SHBASE
# make sure the hash table looks right
hash
# bug in versions of bash up to and including bash-3.2
f() {
v=$'\001'
}
type f | cat -v
+10
View File
@@ -0,0 +1,10 @@
foo()
{
echo $(<x1)
}
type foo
eval "$(declare -f foo | sed 's:foo:bar:')"
type bar