* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
#endif
#endif /* not lint */
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/bin/sh/eval.c 293635 2016-01-10 16:31:28Z jilles $");
+__FBSDID("$FreeBSD: head/bin/sh/eval.c 327212 2017-12-26 16:23:18Z jilles $");
#include <paths.h>
#include <signal.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/resource.h>
-#include <sys/wait.h> /* For WIFSIGNALED(status) */
#include <errno.h>
/*
if (e == EXERROR || e == EXEXEC) {
if (in_redirect) {
exitstatus = 2;
+ FORCEINTON;
return;
}
}
static int
safe_builtin(int idx, int argc, char **argv)
{
- if (idx == BLTINCMD || idx == COMMANDCMD || idx == ECHOCMD ||
- idx == FALSECMD || idx == JOBIDCMD || idx == JOBSCMD ||
- idx == KILLCMD || idx == PRINTFCMD || idx == PWDCMD ||
- idx == TESTCMD || idx == TIMESCMD || idx == TRUECMD ||
- idx == TYPECMD)
+ /* Generated from builtins.def. */
+ if (safe_builtin_always(idx))
return (1);
if (idx == EXPORTCMD || idx == TRAPCMD || idx == ULIMITCMD ||
idx == UMASKCMD)
struct parsefile *savetopfile;
volatile int e;
char *lastarg;
- int realstatus;
+ int signaled;
int do_clearcmdentry;
const char *path = pathval();
int i;
#endif
mode = (cmdentry.u.index == EXECCMD)? 0 : REDIR_PUSH;
if (flags == EV_BACKCMD) {
- memout.nleft = 0;
memout.nextc = memout.buf;
- memout.bufsize = 64;
mode |= REDIR_BACKQ;
}
savecmdname = commandname;
exitshell(exitstatus);
if (flags == EV_BACKCMD) {
backcmd->buf = memout.buf;
- backcmd->nleft = memout.nextc - memout.buf;
+ backcmd->nleft = memout.buf != NULL ?
+ memout.nextc - memout.buf : 0;
memout.buf = NULL;
+ memout.nextc = NULL;
+ memout.bufend = NULL;
+ memout.bufsize = 64;
}
if (cmdentry.u.index != EXECCMD)
popredir();
parent: /* parent process gets here (if we forked) */
if (mode == FORK_FG) { /* argument to fork */
INTOFF;
- exitstatus = waitforjob(jp, &realstatus);
+ exitstatus = waitforjob(jp, &signaled);
INTON;
- if (iflag && loopnest > 0 && WIFSIGNALED(realstatus)) {
+ if (iflag && loopnest > 0 && signaled) {
evalskip = SKIPBREAK;
skipcount = loopnest;
}
return 127;
}
/*
- * Preserve exitstatus of a previous possible redirection
+ * Preserve exitstatus of a previous possible command substitution
* as POSIX mandates
*/
return exitstatus;