Commit Graph

13 Commits

Author SHA1 Message Date
Jilles Tjoelker
2f61288c80 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.

MFC after:	1 week
2015-03-31 20:51:01 +00:00
Jilles Tjoelker
f6d7148dc3 wordexp(): Avoid leaking the pipe file descriptors to a parallel fork/exec.
This uses the new pipe2() system call added on May 1 (r250159).
2013-08-27 21:47:01 +00:00
Jilles Tjoelker
8d0f6b5fc2 wordexp(): Fix syntax validation for backslashes in single-quotes. 2013-07-23 21:09:26 +00:00
Jilles Tjoelker
ae4c676c55 wordexp(): Simplify code by deferring work to sh. 2013-05-09 11:43:45 +00:00
Jilles Tjoelker
70d41b5846 wordexp(): Remove wrong IFS usage.
Words in shell script are separated by spaces or tabs independent of the
value of IFS. The value of IFS is only relevant for the result of
substitutions. Therefore, there should be a space between 'wordexp' and the
words to be expanded, not an IFS character.

Paranoia might dictate that the shell ignore IFS from the environment (even
though our sh currently uses it), so do not depend on it in the new test
case.
2013-04-01 20:50:07 +00:00
Garrett Wollman
0c0349bfa4 Eliminate more dead stores.
Found by:	Clang static analyzer
MFC after:	7 days
2009-11-25 04:45:45 +00:00
Jilles Tjoelker
364e9ccb9c wordexp(3): fix some bugs with signals and long outputs
* retry various system calls on EINTR
* retry the rest after a short read (common if there is more than about 1K
  of output)
* block SIGCHLD like system(3) does (note that this does not and cannot
  work fully in threaded programs, they will need to be careful with wait
  functions)

PR:		90580
MFC after:	1 month
2009-10-23 14:50:11 +00:00
Tim J. Robbins
b7114d4a9c Fix typo: WRDE_DOOFS -> WRDE_DOOFFS.
Noticed by:	Stoned Elipot
2004-06-30 13:55:08 +00:00
Tim J. Robbins
7937c23d49 Terminate execl()'s argument list with a null pointer instead of a
null pointer constant. (The latter may be an integer constant, which
is not correct here.)

Submitted by:	Stefan Farfeleder
2004-04-09 11:32:32 +00:00
Tim J. Robbins
2005f192e5 Use hidden names (_close, _dup2, _waitpid, etc.) where appropriate. 2003-01-07 06:07:56 +00:00
Tim J. Robbins
fe634ca75f Fix a number of bugs noticed by more extensive testing:
o Call waitpid() if an error occurs after forking the child process
   to avoid leaving zombies around.
 o Handle the WRDE_DOOFS|WRDE_APPEND combination correctly
 o Do not confuse $( substitution with $(( shell arithmetic
     (noticed by wollman)
 o Handle backslash escaping properly
 o Allow $( and ${ to be quoted
2003-01-04 06:07:44 +00:00
Tim J. Robbins
97c1c8f886 Be more consistent with "static". 2002-12-27 01:01:03 +00:00
Tim J. Robbins
faea1495bf Add an implementation of the POSIX wordexp() and wordfree() functions,
which perform shell-style word expansion on strings. This is still a
little rough around the edges.

PR:		13420
2002-12-26 14:34:18 +00:00