mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-06-25 14:55:25 +02:00
fix for parameter length expressions for nameref variables expanding to invalid identifiers
This commit is contained in:
@@ -4654,3 +4654,16 @@ sig.c
|
||||
bashline_reset (which zeroes rl_signal_event_hook), call
|
||||
rl_cleanup_after_signal if we think readline hasn't called it
|
||||
already
|
||||
|
||||
12/9
|
||||
----
|
||||
configure.ac
|
||||
- add "LOCAL_LDFLAGS = -rdynamic" for freebsd/openbsd/netbsd. Reported
|
||||
by Christian Weisgerber <naddy@mips.inka.de>
|
||||
|
||||
12/12
|
||||
-----
|
||||
subst.c
|
||||
- parameter_brace_expand_length: handle namerefs with values that are
|
||||
valid length expansion expressions but invalid identifiers. From
|
||||
ed7-aspire4925@hotmail.com via https://savannah.gnu.org/support/?110799
|
||||
|
||||
@@ -1264,6 +1264,7 @@ tests/nameref20.sub f
|
||||
tests/nameref21.sub f
|
||||
tests/nameref22.sub f
|
||||
tests/nameref23.sub f
|
||||
tests/nameref24.sub f
|
||||
tests/nameref.right f
|
||||
tests/new-exp.tests f
|
||||
tests/new-exp1.sub f
|
||||
|
||||
+2
-2
@@ -84,8 +84,8 @@ static int display_traps PARAMS((WORD_LIST *, int));
|
||||
|
||||
/* The trap command:
|
||||
|
||||
trap <arg> <signal ...>
|
||||
trap <signal ...>
|
||||
trap <action> <sigspec ...>
|
||||
trap <signum ...>
|
||||
trap -l
|
||||
trap -p [sigspec ...]
|
||||
trap [--]
|
||||
|
||||
+4
-2
@@ -21,7 +21,7 @@ dnl Process this file with autoconf to produce a configure script.
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
AC_REVISION([for Bash 5.2, version 5.046])dnl
|
||||
AC_REVISION([for Bash 5.2, version 5.047])dnl
|
||||
|
||||
define(bashvers, 5.2)
|
||||
define(relstatus, maint)
|
||||
@@ -1200,7 +1200,9 @@ freebsd[[3-9]]*)
|
||||
if test -x /usr/bin/objformat && test "`/usr/bin/objformat`" = "elf" ; then
|
||||
LOCAL_LDFLAGS=-rdynamic # allow dynamic loading
|
||||
fi ;;
|
||||
freebsdelf*) LOCAL_LDFLAGS=-rdynamic ;; # allow dynamic loading
|
||||
freebsd*) LOCAL_LDFLAGS=-rdynamic ;; # allow dynamic loading
|
||||
openbsd*) LOCAL_LDFLAGS=-rdynamic ;; # allow dynamic loading
|
||||
netbsd*) LOCAL_LDFLAGS=-rdynamic ;; # allow dynamic loading
|
||||
dragonfly*) LOCAL_LDFLAGS=-rdynamic ;; # allow dynamic loading
|
||||
midnightbsd*) LOCAL_LDFLAGS=-rdynamic ;; # allow dynamic loading
|
||||
esac
|
||||
|
||||
@@ -318,6 +318,7 @@ int flags;
|
||||
struct group *gr;
|
||||
int p;
|
||||
char *b;
|
||||
intmax_t xtime;
|
||||
|
||||
st = getstat(f);
|
||||
if (st == NULL)
|
||||
@@ -325,20 +326,23 @@ int flags;
|
||||
|
||||
/* Print requested info */
|
||||
if (flags & OPT_ATIME) {
|
||||
xtime = st->st_atime;
|
||||
if (flags & OPT_ASCII)
|
||||
printf("%s", ctime(&st->st_atime));
|
||||
else
|
||||
printf("%ld\n", st->st_atime);
|
||||
printf("%jd\n", xtime);
|
||||
} else if (flags & OPT_MTIME) {
|
||||
xtime = st->st_mtime;
|
||||
if (flags & OPT_ASCII)
|
||||
printf("%s", ctime(&st->st_mtime));
|
||||
else
|
||||
printf("%ld\n", st->st_mtime);
|
||||
printf("%jd\n", xtime);
|
||||
} else if (flags & OPT_CTIME) {
|
||||
xtime = st->st_ctime;
|
||||
if (flags & OPT_ASCII)
|
||||
printf("%s", ctime(&st->st_ctime));
|
||||
else
|
||||
printf("%ld\n", st->st_ctime);
|
||||
printf("%jd\n", xtime);
|
||||
} else if (flags & OPT_DEV)
|
||||
printf("%lu\n", (unsigned long)st->st_dev);
|
||||
else if (flags & OPT_INO)
|
||||
|
||||
+4
-1
@@ -3648,7 +3648,10 @@ execute_case_command (case_command)
|
||||
free (pattern);
|
||||
|
||||
dispose_words (es);
|
||||
CHECK_TERMSIG;
|
||||
|
||||
/* sm_loop.c:GMATCH returns failure on interrupt_state or
|
||||
terminating_signal, so we check for those here. */
|
||||
QUIT;
|
||||
|
||||
if (match)
|
||||
{
|
||||
|
||||
@@ -9,7 +9,7 @@ msgstr ""
|
||||
"Project-Id-Version: bash-5.2-rc1\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2022-01-11 14:50-0500\n"
|
||||
"PO-Revision-Date: 2022-11-29 14:23+0900\n"
|
||||
"PO-Revision-Date: 2022-12-10 01:12+0900\n"
|
||||
"Last-Translator: Seong-ho Cho <darkcircle.0426@gmail.com>\n"
|
||||
"Language-Team: Korean <translation-team-ko@googlegroups.com>\n"
|
||||
"Language: ko\n"
|
||||
@@ -1573,12 +1573,12 @@ msgstr "조건 명령어에서 예기치 않은 토큰 %d"
|
||||
#: parse.y:6118
|
||||
#, c-format
|
||||
msgid "syntax error near unexpected token `%s'"
|
||||
msgstr "예기치 않은 토큰 `%s' 근처에서 문법 오류"
|
||||
msgstr "예기치 않은 `%s' 토큰 주변에서 문법 오류"
|
||||
|
||||
#: parse.y:6137
|
||||
#, c-format
|
||||
msgid "syntax error near `%s'"
|
||||
msgstr "`%s' 근처에서 문법 오류"
|
||||
msgstr "`%s' 주변에서 문법 오류"
|
||||
|
||||
#: parse.y:6151
|
||||
msgid "syntax error: unexpected end of file"
|
||||
|
||||
@@ -8068,8 +8068,23 @@ parameter_brace_expand_length (name)
|
||||
else if ((var || (var = find_variable (name + 1))) &&
|
||||
invisible_p (var) == 0 &&
|
||||
array_p (var) == 0 && assoc_p (var) == 0 &&
|
||||
nameref_p (var) == 0 &&
|
||||
var->dynamic_value == 0)
|
||||
number = value_cell (var) ? MB_STRLEN (value_cell (var)) : 0;
|
||||
else if ((var = find_variable_last_nameref (name + 1, 0)) && nameref_p (var))
|
||||
{
|
||||
/* nameref that resolves to unset variable or non-identifier */
|
||||
newname = nameref_cell (var);
|
||||
if (newname && *newname)
|
||||
{
|
||||
newname = (char *)xmalloc (strlen (nameref_cell (var)) + 2);
|
||||
newname[0] = '#';
|
||||
strcpy (newname + 1, nameref_cell (var));
|
||||
if (valid_length_expression (newname))
|
||||
number = parameter_brace_expand_length (newname);
|
||||
free (newname);
|
||||
}
|
||||
}
|
||||
else if (var == 0 && unbound_vars_is_error == 0)
|
||||
number = 0;
|
||||
else /* ${#PS1} */
|
||||
|
||||
@@ -558,3 +558,14 @@ declare -ai a=([0]="0" [1]="16")
|
||||
12
|
||||
16
|
||||
declare -ai a=([0]="0" [1]="16")
|
||||
./nameref24.sub: line 24: declare: `': not a valid identifier
|
||||
./nameref24.sub: line 25: declare: `a&b': invalid variable name for name reference
|
||||
3
|
||||
3
|
||||
0
|
||||
0
|
||||
0
|
||||
./nameref24.sub: line 38: declare: `aa&bb': invalid variable name for name reference
|
||||
3
|
||||
3
|
||||
5
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
# 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/>.
|
||||
#
|
||||
# issues with taking the length of nameref variables
|
||||
#
|
||||
# just the basics
|
||||
|
||||
scalar=foo
|
||||
declare -a array=(foo)
|
||||
|
||||
declare -n name=array
|
||||
declare -n name1=array[0]
|
||||
declare -n name2=unset
|
||||
declare -n name3=
|
||||
declare -n name4='a&b'
|
||||
|
||||
echo ${#name} # length of nameref resolving to set variable
|
||||
echo ${#name1} # length of nameref resolving to valid non-identifier
|
||||
echo ${#name2} # length of nameref resolving to unset variable
|
||||
echo ${#name3} # length of nameref resolving to empty string
|
||||
echo ${#name4} # length of nameref resolving to invalid non-identifier
|
||||
|
||||
unset -n name name1
|
||||
|
||||
declare -n name=scalar
|
||||
declare -n name1=scalar[0]
|
||||
name4='aa&bb'
|
||||
declare -n name4
|
||||
|
||||
echo ${#name} # length of nameref resolving to set variable
|
||||
echo ${#name1} # length of nameref resolving to valid non-identifier
|
||||
echo ${#name4} # length of nameref resolving to invalid non-identifier
|
||||
Reference in New Issue
Block a user