summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2015-04-19 13:51:25 +0000
committerjilles <jilles@FreeBSD.org>2015-04-19 13:51:25 +0000
commitbde9d93b63f0e234f2b82c33c2bd40b6f36b277d (patch)
treed5d20584c4665b8e63816a96cc1449b6d3ade575 /lib
parent87307718d2a664b264cd061938f5292a1ec168b4 (diff)
downloadFreeBSD-src-bde9d93b63f0e234f2b82c33c2bd40b6f36b277d.zip
FreeBSD-src-bde9d93b63f0e234f2b82c33c2bd40b6f36b277d.tar.gz
MFC r280919: wordexp: Explicitly pass along IFS.
Per Austin group issue #884, sh should not import IFS from the environment but always set it to $' \t\n'. For wordexp(), however, it is documented and useful for it to use IFS from the environment. Since sh currently imports IFS from the environment, this change has no functional effect.
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/gen/wordexp.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/libc/gen/wordexp.c b/lib/libc/gen/wordexp.c
index 377caff..c7f4b1d 100644
--- a/lib/libc/gen/wordexp.c
+++ b/lib/libc/gen/wordexp.c
@@ -118,8 +118,10 @@ we_askshell(const char *words, wordexp_t *we, int flags)
char *nstrings; /* Temporary for realloc() */
char **nwv; /* Temporary for realloc() */
sigset_t newsigblock, oldsigblock;
+ const char *ifs;
serrno = errno;
+ ifs = getenv("IFS");
if (pipe2(pdes, O_CLOEXEC) < 0)
return (WRDE_NOSPACE); /* XXX */
@@ -145,7 +147,8 @@ we_askshell(const char *words, wordexp_t *we, int flags)
_fcntl(pdes[1], F_SETFD, 0)) < 0)
_exit(1);
execl(_PATH_BSHELL, "sh", flags & WRDE_UNDEF ? "-u" : "+u",
- "-c", "eval \"$1\";eval \"wordexp $2\"", "",
+ "-c", "IFS=$1;eval \"$2\";eval \"wordexp $3\"", "",
+ ifs != NULL ? ifs : " \t\n",
flags & WRDE_SHOWERR ? "" : "exec 2>/dev/null", words,
(char *)NULL);
_exit(1);
OpenPOWER on IntegriCloud