summaryrefslogtreecommitdiffstats
path: root/bin/sh/expand.c
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2014-10-28 22:14:31 +0000
committerjilles <jilles@FreeBSD.org>2014-10-28 22:14:31 +0000
commit10a925c0a7cdeafe07ede1a1e848377970d03b2a (patch)
treebff51b62df045acab93fc518d065dddfe5e233c3 /bin/sh/expand.c
parentd47eb7d2d46dabce3135bac7e98b771b40aff97d (diff)
downloadFreeBSD-src-10a925c0a7cdeafe07ede1a1e848377970d03b2a.zip
FreeBSD-src-10a925c0a7cdeafe07ede1a1e848377970d03b2a.tar.gz
Treat IFS separators in "$*" as quoted.
This makes a difference if IFS starts with *, ?, [ or a CTL* byte.
Diffstat (limited to 'bin/sh/expand.c')
-rw-r--r--bin/sh/expand.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/bin/sh/expand.c b/bin/sh/expand.c
index e0be64a..0a9d329 100644
--- a/bin/sh/expand.c
+++ b/bin/sh/expand.c
@@ -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:
OpenPOWER on IntegriCloud