Treat IFS separators in "$*" as quoted.

This makes a difference if IFS starts with *, ?, [ or a CTL* byte.
This commit is contained in:
Jilles Tjoelker 2014-10-28 22:14:31 +00:00
parent 01e1933dcc
commit 3fb51b3a43
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=273802
4 changed files with 25 additions and 5 deletions

View File

@ -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:

View File

@ -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

View File

@ -0,0 +1,7 @@
# $FreeBSD$
IFS=?
set p r
v=pqrs
r=${v#"$*"}
[ "$r" = pqrs ]

View File

@ -0,0 +1,8 @@
# $FreeBSD$
set -- / ''
IFS=*
set -- "$*"
IFS=:
args="$*"
[ "$#:$args" = "1:/*" ]