Treat IFS separators in "$*" as quoted.
This makes a difference if IFS starts with *, ?, [ or a CTL* byte.
This commit is contained in:
parent
01e1933dcc
commit
3fb51b3a43
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=273802
@ -878,7 +878,7 @@ varvalue(const char *name, int quoted, int subtype, int flag)
|
||||
int num;
|
||||
char *p;
|
||||
int i;
|
||||
char sep;
|
||||
char sep[2];
|
||||
char **ap;
|
||||
|
||||
switch (*name) {
|
||||
@ -912,15 +912,18 @@ varvalue(const char *name, int quoted, int subtype, int flag)
|
||||
/* FALLTHROUGH */
|
||||
case '*':
|
||||
if (ifsset())
|
||||
sep = ifsval()[0];
|
||||
sep[0] = ifsval()[0];
|
||||
else
|
||||
sep = ' ';
|
||||
sep[0] = ' ';
|
||||
sep[1] = '\0';
|
||||
for (ap = shellparam.p ; (p = *ap++) != NULL ; ) {
|
||||
strtodest(p, flag, subtype, quoted);
|
||||
if (!*ap)
|
||||
break;
|
||||
if (sep || (flag & EXP_FULL && !quoted && **ap != '\0'))
|
||||
STPUTC(sep, expdest);
|
||||
if (sep[0])
|
||||
strtodest(sep, flag, subtype, quoted);
|
||||
else if (flag & EXP_FULL && !quoted && **ap != '\0')
|
||||
STPUTC('\0', expdest);
|
||||
}
|
||||
return;
|
||||
default:
|
||||
|
@ -18,6 +18,8 @@ FILES+= positional2.0
|
||||
FILES+= positional3.0
|
||||
FILES+= positional4.0
|
||||
FILES+= positional5.0
|
||||
FILES+= positional6.0
|
||||
FILES+= positional7.0
|
||||
FILES+= pwd1.0
|
||||
FILES+= pwd2.0
|
||||
|
||||
|
7
bin/sh/tests/parameters/positional6.0
Normal file
7
bin/sh/tests/parameters/positional6.0
Normal file
@ -0,0 +1,7 @@
|
||||
# $FreeBSD$
|
||||
|
||||
IFS=?
|
||||
set p r
|
||||
v=pqrs
|
||||
r=${v#"$*"}
|
||||
[ "$r" = pqrs ]
|
8
bin/sh/tests/parameters/positional7.0
Normal file
8
bin/sh/tests/parameters/positional7.0
Normal file
@ -0,0 +1,8 @@
|
||||
# $FreeBSD$
|
||||
|
||||
set -- / ''
|
||||
IFS=*
|
||||
set -- "$*"
|
||||
IFS=:
|
||||
args="$*"
|
||||
[ "$#:$args" = "1:/*" ]
|
Loading…
Reference in New Issue
Block a user