1/*- 2 * Copyright (c) 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Kenneth Almquist. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 22 unchanged lines hidden (view full) --- 31 */ 32 33#ifndef lint 34#if 0 35static char sccsid[] = "@(#)eval.c 8.9 (Berkeley) 6/8/95"; 36#endif 37#endif /* not lint */ 38#include <sys/cdefs.h> |
39__FBSDID("$FreeBSD: head/bin/sh/eval.c 272575 2014-10-05 21:51:36Z jilles $"); |
40 41#include <paths.h> 42#include <signal.h> 43#include <stdlib.h> 44#include <unistd.h> 45#include <sys/resource.h> 46#include <sys/wait.h> /* For WIFSIGNALED(status) */ 47#include <errno.h> --- 263 unchanged lines hidden (view full) --- 311static void 312evalloop(union node *n, int flags) 313{ 314 int status; 315 316 loopnest++; 317 status = 0; 318 for (;;) { |
319 if (!evalskip) 320 evaltree(n->nbinary.ch1, EV_TESTED); |
321 if (evalskip) { |
322 if (evalskip == SKIPCONT && --skipcount <= 0) { |
323 evalskip = 0; 324 continue; 325 } 326 if (evalskip == SKIPBREAK && --skipcount <= 0) 327 evalskip = 0; 328 if (evalskip == SKIPRETURN) 329 status = exitstatus; 330 break; 331 } 332 if (n->type == NWHILE) { 333 if (exitstatus != 0) 334 break; 335 } else { 336 if (exitstatus == 0) 337 break; 338 } 339 evaltree(n->nbinary.ch2, flags); 340 status = exitstatus; |
341 } 342 loopnest--; 343 exitstatus = status; 344} 345 346 347 348static void --- 293 unchanged lines hidden (view full) --- 642{ 643 int pip[2]; 644 struct job *jp; 645 struct stackmark smark; 646 struct jmploc jmploc; 647 struct jmploc *savehandler; 648 struct localvar *savelocalvars; 649 |
650 result->fd = -1; 651 result->buf = NULL; 652 result->nleft = 0; 653 result->jp = NULL; 654 if (n == NULL) { 655 exitstatus = 0; |
656 return; |
657 } |
658 setstackmark(&smark); |
659 exitstatus = oexitstatus; 660 if (is_valid_fast_cmdsubst(n)) { 661 savelocalvars = localvars; 662 localvars = NULL; 663 forcelocal++; 664 savehandler = handler; 665 if (setjmp(jmploc.loc)) { 666 if (exception == EXERROR || exception == EXEXEC) --- 25 unchanged lines hidden (view full) --- 692 close(pip[1]); 693 } 694 evaltree(n, EV_EXIT); 695 } 696 close(pip[1]); 697 result->fd = pip[0]; 698 result->jp = jp; 699 } |
700 popstackmark(&smark); 701 TRACE(("evalbackcmd done: fd=%d buf=%p nleft=%d jp=%p\n", 702 result->fd, result->buf, result->nleft, result->jp)); 703} 704 705static int 706mustexpandto(const char *argtext, const char *mask) 707{ --- 680 unchanged lines hidden --- |