bash-5.2-beta release

This commit is contained in:
Chet Ramey
2022-04-13 11:01:08 -04:00
parent 4491c03014
commit 187661b892
119 changed files with 14991 additions and 12391 deletions
+3 -1
View File
@@ -13,9 +13,11 @@
#
# this is a new feature: expanding aliases when initially parsing command
# substitutions
# substitutions. required by posix, so enabled in posix mode. default mode
# stays backwards compatible.
shopt -s expand_aliases
set -o posix
alias switch=case
+19
View File
@@ -1,3 +1,17 @@
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# first, let's start with the basics
recho "$@"
@@ -246,6 +260,11 @@ ${THIS_SH} ./dollar-at-star8.sub
# with different values for IFS
${THIS_SH} ./dollar-at-star9.sub
# tests for expansions of "$*" and "$@" and their array equivalents when $1 == ''
# and we're using the POSIX word expansions
${THIS_SH} ./dollar-at-star10.sub
${THIS_SH} ./dollar-at-star11.sub
# tests for special expansion of "$*" and "${array[*]}" when used with other
# expansions -- bugs through bash-2.05b
${THIS_SH} ./dollar-star1.sub
+66
View File
@@ -0,0 +1,66 @@
# checks for array variables and positional parameter expansions losing quoted
# null string expansions -- problem through bash-5.1
set -- ''
myvar[0]=
a="${myvar[*]}"
recho "$*"
recho "${*}"
recho "${a}"
recho "${myvar[*]}"
recho "${a:+nonnull}"
recho "${myvar[*]:+nonnull}"
a="${myvar[@]}"
recho "$@"
recho "${@}"
recho "${a}"
recho "${myvar[@]}"
recho "${a:+nonnull}"
recho "${myvar[@]:+nonnull}"
# check to make sure literal CTLNULs are handled correctly
set -- $'\x7f'
recho "$@"
recho "${@}"
recho "${@:+nonnull}"
recho "$*"
recho "${*}"
recho "${*:+nonnull}"
shift $#
# these should echo nothing
recho "${@}"
recho "${@:+nonnull}"
unset -v a
# make sure that other null expansions result in null strings where appropriate
set -- ''
a[0]=
recho "$*"$x
recho "${*}"$x
recho "$@"$x
recho "${@}"$x
recho "${a[*]}"$x
recho "${a[@]}"$x
recho "$@"$x
recho "${@}"$x
recho "${a[*]}"
recho "${a[@]}"
+80
View File
@@ -0,0 +1,80 @@
a[0]='/'
set -- /
# these should all result in the empty (null) string
recho "${a[0]%?}"
recho "${a[*]%?}"
recho "${a[@]%?}"
recho "${*%?}"
recho "${@%?}"
recho "${a[0]#?}"
recho "${a[*]#?}"
recho "${a[@]#?}"
recho "${*#?}"
recho "${@#?}"
recho "${a[0]/\//}"
recho "${a[*]/\//}"
recho "${a[@]/\//}"
recho "${*/\//}"
recho "${@/\//}"
recho "${a[0]:1:1}"
# these next four will all echo /
# arrays are zero-based
recho "${a[*]:0:1}"
recho "${a[@]:0:1}"
# but the positional parameters start at 1
recho "${*:1:1}"
recho "${@:1:1}"
a[0]=''
set -- ''
# arrays are zero-based
recho "${a[*]:0:1}"
recho "${a[@]:0:1}"
recho "${*:1:1}"
recho "${@:1:1}"
# these should all result in the empty (null) string, or quoted as such
recho "${a[0]@Q}"
recho "${a[*]@Q}"
recho "${a[@]@Q}"
recho "${*@Q}"
recho "${@@Q}"
recho "${a[0]@L}"
recho "${a[*]@L}"
recho "${a[@]@L}"
recho "${*@L}"
recho "${@@L}"
# examples from the bug report
unset -v a
a[0]='/'
for i in "${a[@]%/}"; do recho "$i"; done
a[0]=''
for i in "${a[@]}"; do recho "$i"; done
a[0]='/'
a[1]="//"
for i in "${a[@]%/}"; do recho "$i"; done
unset -v x y
x=('/')
y=("${x[@]%/}")
echo "${#x[@]}:${#y[@]}"
+67
View File
@@ -399,6 +399,73 @@ argv[1] = <^?>
argv[1] = <^?>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <^?>
argv[1] = <^?>
argv[1] = <nonnull>
argv[1] = <^?>
argv[1] = <^?>
argv[1] = <nonnull>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = </>
argv[1] = </>
argv[1] = </>
argv[1] = </>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <''>
argv[1] = <''>
argv[1] = <''>
argv[1] = <''>
argv[1] = <''>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = <>
argv[1] = </>
1:1
xa|xb|xc
xa|xb|xc
a|b|c
+28
View File
@@ -142,3 +142,31 @@ w
x
y
z
=====
WORKS
done
WORKS
a
b
c
d
a
b
c
d
e
A
B
c
d
c
d
e
x
y
z
WORKS
w
x
y
z
+17
View File
@@ -45,3 +45,20 @@ $THIS_SH -c '$binecho c && $binecho d && echo e'
$THIS_SH -c 'trap "echo WORKS" EXIT ; $binecho x ; $binecho y ; $binecho z'
${THIS_SH} -c 'echo w ; { echo x ; $binecho y; }; $binecho z'
echo =====
( trap "echo WORKS && rm $TMPDIR/x$$" EXIT && touch $TMPDIR/x$$ )
( trap "echo WORKS && rm $TMPDIR/x$$" EXIT && touch $TMPDIR/x$$ ; $binecho done )
( echo a && { $binecho b && $binecho c ; } && echo d )
( echo a && { $binecho b && $binecho c ; } && echo d ; $binecho e )
( echo A && $binecho B )
( $binecho c && echo d )
( $binecho c && $binecho d && echo e )
( trap "echo WORKS" EXIT ; $binecho x ; $binecho y ; $binecho z )
( echo w ; { echo x ; $binecho y; }; $binecho z )
+8
View File
@@ -13,6 +13,14 @@
#
. ./test-glue-functions
# this locale causes problems all over the place
if locale -a | grep -i '^zh_HK\.big5hkscs' >/dev/null ; then
:
else
echo "glob2.sub: warning: you do not have the zh_HK.big5hkscs locale installed;" >&2
echo "glob2.sub: warning: that will cause some of these tests to fail." >&2
fi
var='ab\'
case $var in
+21 -1
View File
@@ -1,5 +1,25 @@
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# this locale causes problems all over the place
unset LC_ALL LC_NUMERIC
export LANG=de_DE.UTF-8
if locale -a | grep -i '^de_DE\.UTF.*8' >/dev/null ; then
export LANG=de_DE.UTF-8
else
echo "intl2.sub: warning: you do not have the de_DE.UTF-8 locale installed;" >&2
echo "intl2.sub: that will cause some of these tests to fail." >&2
fi
printf '%.4f\n' 1
LANG=C printf '%.4f\n' 1
+1
View File
@@ -32,6 +32,7 @@ i killed it
2: ok 2
2: ok 3
127
./jobs5.sub: line 71: declare: wpid: not found
child1 exit status 0
[1]+ Running sleep 20 &
./jobs7.sub: line 5: fg: no current jobs
+5
View File
@@ -64,3 +64,8 @@ unset wpid
jobs
wait -n -p wpid
echo $wpid $?
# make sure wait -p var does something useful without the -n option
jobs
wait -p wpid
declare -p wpid
+27 -6
View File
@@ -735,30 +735,51 @@ a
defg
defg
defg
$'&' $'&' $'&' $'&' $'&' $'&' $'&'
$'a' $'b' $'c' $'d' $'e' $'f' $'g'
a b c d e f g
a b c d e f g
a b c d e f g
& & & & & & &
& & & & & & &
& & & & & & &
\& \& \& \& \& \& \&
a a a a a a a
3 3 3 3 3 3 3
abc defg
abc defg
abc defg
abc defg
abc defg
& defg
& defg
& defg
\& defg
\abc defg
abcdefg
abcdefg
&defg
&defg
\abcdefg
\&defg
\&defg
\abcdefg
\\&defg
&defg
&defg
\&defg
\&defg
\\&defg
letx&yee
letx&yee
letxssyee
letxssyee
letx\&yee
letx\&yee
letx&yee
letx&yee
let\&ee
let\\ssee
let\ssee
let\ssee
let\&ee
let\&ee
let&ee
let&ee
argv[1] = </>
argv[1] = </>
+40
View File
@@ -16,6 +16,8 @@ HOME=/homes/chet
string=abcdefg
set -- a b c
shopt -u patsub_replacement
# verify existing behavior
echo ${string/abc/~}
echo "${string/abc/~}"
@@ -29,6 +31,11 @@ echo ${string//?/\$\'&\' }
shopt -s patsub_replacement
echo ${string//?/\$\'&\' }
echo ${string//?/& }
echo "${string//?/& }"
echo ${string//?/\& }
echo "${string//?/\& }"
echo ${string//?/"& "}
@@ -51,7 +58,9 @@ rep='\\&'
echo "${string/abc/&}"
echo ${string/abc/\&}
echo "${string/abc/\\&}"
echo ${string/abc/"\\&"}
echo "${string/abc/"\\&"}"
echo ${string/abc/$rep}
echo ${string/abc/"$rep"}
shopt -u patsub_replacement
@@ -61,3 +70,34 @@ echo ${string/abc/\&}
echo "${string/abc/\\&}"
echo "${string/abc/"\\&"}"
echo ${string/abc/"$rep"}
shopt -s patsub_replacement
repl='x&y'
r2='x\&y'
var='letssee'
pat=ss
echo ${var//$pat/"$repl"}
echo "${var//$pat/"$repl"}"
echo ${var//$pat/$repl}
echo "${var//$pat/$repl}"
echo ${var//$pat/"$r2"}
echo "${var//$pat/"$r2"}"
echo ${var//$pat/$r2}
echo "${var//$pat/$r2}"
r2='\\&'
r3='\&'
echo ${var//$pat/\\\&}
echo ${var//$pat/\\$r2}
echo ${var//$pat/\\&}
echo ${var//$pat/$r2}
echo ${var//$pat/"\&"}
echo ${var//$pat/"$r3"}
echo ${var//$pat/"&"}
echo ${var//$pat/$r3}
+10
View File
@@ -68,3 +68,13 @@ argv[1] = <^?>
\q
foo
./nquote4.sub: line 6: quux: command not found
argv[1] = <a^A)b>
argv[1] = <a^Ab>
argv[1] = <^A>
argv[1] = <\^A>
0000000 a $ ' \ 0 1 ' b \n a 001 b \n
0000015
0000000 a $ ' \ 0 1 ' b \n a 001 b \n
0000015
0000000 A \n A \n
0000004
+1
View File
@@ -139,3 +139,4 @@ ${THIS_SH} ./nquote1.sub
${THIS_SH} ./nquote2.sub
${THIS_SH} ./nquote3.sub
${THIS_SH} ./nquote4.sub
${THIS_SH} ./nquote5.sub
+36
View File
@@ -0,0 +1,36 @@
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
. test-glue-functions
recho $( echo a$'\01)'b )
recho $( echo ab )
recho $( echo \ )
recho $( echo \\ )
LC_CTYPE=C
od -c <<EOF | _intl_normalize_spaces
a$'\01'b
ab
EOF
od -c <<EOF | _intl_normalize_spaces
${none-a$'\01'b}
${none-ab}
EOF
V=Aa$'\01'b
od -c <<EOF | _intl_normalize_spaces
${V%a$'\01'b}
${V%ab}
EOF
+23 -3
View File
@@ -275,11 +275,31 @@ argv[2] = <b>
[ abc def ghi jkl / abc def ghi jkl ]
[ abc def ghi jkl ]
[ abc def ghi jkl / abc def ghi jkl / abc def ghi jkl ]
5: OK
1: OK
2: $'not'
3: OK
4: OK
5: tOK
OK
OK
5: 'not too
bad'
$'not'
OK
tOK
6: $'not\ttoo\nbad'
OKa ' b
OKa ' b
7: OK
8: OKa ' b
9: OKa " b
10: OKa " b
tOK
tOK
tOK
tOK
./posixexp7.sub: line 69: ${'x1'%'t'}: bad substitution
./posixexp7.sub: line 70: ${'x1'%'t'}: bad substitution
./posixexp7.sub: line 73: ${'x1'%'t'}: bad substitution
./posixexp7.sub: line 74: ${'x1'%'t'}: bad substitution
"A"
A
argv[1] = <"A">
+66 -3
View File
@@ -1,13 +1,76 @@
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# test the effect of quotes on the WORD in the posix pattern removal operators
# a here document does not behave the same as double quotes
#
x=notOK
x1=not
cat <<EOF
5: ${x#$'not'}
1: ${x#$'not'}
2: $'not'
3: ${x#"not"}
4: ${x#'not'}
5: ${x#${x1%'t'}}
EOF
echo "${x#'not'}"
echo "${x#$'not'}"
echo "$'not'"
echo "${x#"not"}"
echo "${x#${x1%'t'}}"
cat <<EOF
5: $'not\ttoo\nbad'
6: $'not\ttoo\nbad'
EOF
x=OK$'a\t\'\tb'
echo OK$'a\t\'\tb'
echo "$x"
cat <<EOF
7: ${x%$'a\t\'\tb'}
8: ${x#$'a\t\'\tb'}
EOF
x=OK'a " b'
cat <<EOF
9: ${x#'a " b'}
10: ${x#$'a " b'}
EOF
x=notOK
x1=not
# extquote makes these work
echo "${x#${$'x1'%$'t'}}"
cat <<EOF
${x#${$'x1'%$'t'}}
EOF
echo "${x#${$'x1'%'t'}}"
cat <<EOF
${x#${$'x1'%'t'}}
EOF
# syntax errors
echo "${x#${'x1'%'t'}}"
cat <<EOF
${x#${'x1'%'t'}}
EOF
echo "${x#${'x1'%$'t'}}"
cat <<EOF
${x#${'x1'%$'t'}}
EOF
+1
View File
@@ -78,6 +78,7 @@ unset or null 3
timeout 4: ok
abcde
abcde
one
two three four
one
+5
View File
@@ -59,3 +59,8 @@ echo abcde | {
read -e -t .0001 a <<<abcde
echo $a
set -o posix
read -t 0.1 a </dev/tty
echo $a
-3
View File
@@ -1,8 +1,5 @@
# See whether or not we can use `diff -a'
( diff -a ./intl.right ./intl.right >/dev/null 2>&1 ) && AFLAG=-a
echo "warning: some of these tests will fail if you do not have UTF-8" >&2
echo "warning: locales installed on your system." >&2
${THIS_SH} ./intl.tests > ${BASH_TSTOUT}
diff $AFLAG ${BASH_TSTOUT} intl.right && rm -f ${BASH_TSTOUT}
+8 -1
View File
@@ -109,7 +109,14 @@ fr_FR_ISO_8859_1=(
[0x00fb]=$'\373' [0x00fc]=$'\374' [0x00fd]=$'\375' [0x00fe]=$'\376'
)
TestCodePage fr_FR.ISO8859-1 fr_FR_ISO_8859_1
# this locale causes problems all over the place
if locale -a | grep -i '^fr_FR\.ISO8859.*1' >/dev/null ; then
TestCodePage fr_FR.ISO8859-1 fr_FR_ISO_8859_1
else
echo "unicode1.sub: warning: you do not have the fr_FR.ISO8859-1 locale installed;" >&2
echo "unicode1.sub: that will cause some of these tests to fail." >&2
fi
zh_TW_BIG5=(
[0x00f6]=$'\366' [0x00f7]=$'\367' [0x00f8]=$'\370' [0x00f9]=$'\371' [0x00fa]=$'\372'