mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-07-04 19:00:50 +02:00
fix for namerefs referencing an unset array index with nounset enabled; addition to buildconf.h.in for C23 compilers
This commit is contained in:
@@ -78,6 +78,9 @@ a ../a.cfg
|
||||
a.. /a.cfg
|
||||
a..b /a.cfg
|
||||
a b../a.cfg
|
||||
1..4 5..8
|
||||
1..4 8
|
||||
1 5..8
|
||||
{abcde.f}
|
||||
X{..a}Z
|
||||
0{1..}2
|
||||
|
||||
@@ -147,6 +147,10 @@ echo {a..,/a.cfg}
|
||||
echo {a..b,/a.cfg}
|
||||
echo {a,b../a.cfg}
|
||||
|
||||
echo {1..4,5..8}
|
||||
echo {1..4,8}
|
||||
echo {1,5..8}
|
||||
|
||||
# these are all invalid brace expansions
|
||||
|
||||
echo {abcde.f}
|
||||
|
||||
+15
-3
@@ -535,16 +535,16 @@ declare -ai a=([0]="5")
|
||||
declare -ai a=([0]="6")
|
||||
declare -ai a=([0]="42")
|
||||
declare -ai a=([0]="1")
|
||||
./nameref23.sub: line 16: declare: b: not found
|
||||
./nameref23.sub: line 29: declare: b: not found
|
||||
declare -ai a=([0]="1")
|
||||
declare -- b="1"
|
||||
declare -ai a=([0]="1")
|
||||
declare -- b="11"
|
||||
declare -ai a=([0]="1")
|
||||
declare -- b="110"
|
||||
./nameref23.sub: line 26: declare: `1': invalid variable name for name reference
|
||||
./nameref23.sub: line 39: declare: `1': invalid variable name for name reference
|
||||
declare -ai a=([0]="1")
|
||||
./nameref23.sub: line 28: declare: b: not found
|
||||
./nameref23.sub: line 41: declare: b: not found
|
||||
declare -ai a=([0]="4")
|
||||
declare -in b="a[0]"
|
||||
declare -ai a=([0]="6")
|
||||
@@ -574,3 +574,15 @@ declare -ai a=([0]="0" [1]="16")
|
||||
3
|
||||
3
|
||||
5
|
||||
/usr/local/build/bash/bash-current/bash: line 1: a[k]: unbound variable
|
||||
ok 1
|
||||
/usr/local/build/bash/bash-current/bash: line 1: r0: unbound variable
|
||||
ok 2
|
||||
/usr/local/build/bash/bash-current/bash: line 1: r: unbound variable
|
||||
ok 3
|
||||
/usr/local/build/bash/bash-current/bash: line 1: k: unbound variable
|
||||
ok 4
|
||||
ok 5
|
||||
ok 6
|
||||
ok 7
|
||||
ok 8
|
||||
|
||||
@@ -1,3 +1,16 @@
|
||||
# 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/>.
|
||||
#
|
||||
declare -ai a
|
||||
a[0]=4
|
||||
declare -n b='a[0]'
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
# issues with nounset and references to nameref variables whose value
|
||||
# contains an unset variable
|
||||
|
||||
$THIS_SH -uc 'a=() k=; "${a[k]}"' || echo ok 1
|
||||
$THIS_SH -uc 'declare -n r0=b ; : "$r0"' || echo ok 2
|
||||
$THIS_SH -uc 'a=() k=; declare -n r='a[k]' ; : "$r"' || echo ok 3
|
||||
$THIS_SH -uc 'declare -n r='a[k]' ; : "$r"' || echo ok 4
|
||||
|
||||
$THIS_SH -uc 'a=() k=; declare -n r='a[@]' ; : "$r"' && echo ok 5
|
||||
$THIS_SH -uc 'declare -n r='a[@]' ; : "$r"' && echo ok 6
|
||||
$THIS_SH -uc 'a=() k=; declare -n r='a[*]' ; : "$r"' && echo ok 7
|
||||
$THIS_SH -uc 'declare -n r='a[*]' ; : "$r"' && echo ok 8
|
||||
Reference in New Issue
Block a user