Deleted Added
full compact
eval.c (205138) eval.c (205154)
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>
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 205138 2010-03-13 22:53:17Z jilles $");
39__FBSDID("$FreeBSD: head/bin/sh/eval.c 205154 2010-03-14 14:24:35Z 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>

--- 38 unchanged lines hidden (view full) ---

86int exitstatus; /* exit status of last command */
87int oexitstatus; /* saved exit status */
88
89
90STATIC void evalloop(union node *, int);
91STATIC void evalfor(union node *, int);
92STATIC void evalcase(union node *, int);
93STATIC void evalsubshell(union node *, int);
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>

--- 38 unchanged lines hidden (view full) ---

86int exitstatus; /* exit status of last command */
87int oexitstatus; /* saved exit status */
88
89
90STATIC void evalloop(union node *, int);
91STATIC void evalfor(union node *, int);
92STATIC void evalcase(union node *, int);
93STATIC void evalsubshell(union node *, int);
94STATIC void evalredir(union node *, int);
94STATIC void expredir(union node *);
95STATIC void evalpipe(union node *);
96STATIC void evalcommand(union node *, int, struct backcmd *);
97STATIC void prehash(union node *);
98
99
100/*
101 * Called to reset things after an exception.

--- 114 unchanged lines hidden (view full) ---

216 break;
217 case NOR:
218 evaltree(n->nbinary.ch1, EV_TESTED);
219 if (evalskip || exitstatus == 0)
220 goto out;
221 evaltree(n->nbinary.ch2, flags);
222 break;
223 case NREDIR:
95STATIC void expredir(union node *);
96STATIC void evalpipe(union node *);
97STATIC void evalcommand(union node *, int, struct backcmd *);
98STATIC void prehash(union node *);
99
100
101/*
102 * Called to reset things after an exception.

--- 114 unchanged lines hidden (view full) ---

217 break;
218 case NOR:
219 evaltree(n->nbinary.ch1, EV_TESTED);
220 if (evalskip || exitstatus == 0)
221 goto out;
222 evaltree(n->nbinary.ch2, flags);
223 break;
224 case NREDIR:
224 expredir(n->nredir.redirect);
225 redirect(n->nredir.redirect, REDIR_PUSH);
226 evaltree(n->nredir.n, flags);
227 popredir();
225 evalredir(n, flags);
228 break;
229 case NSUBSHELL:
230 evalsubshell(n, flags);
231 do_etest = !(flags & EV_TESTED);
232 break;
233 case NBACKGND:
234 evalsubshell(n, flags);
235 break;

--- 174 unchanged lines hidden (view full) ---

410 } else if (! backgnd) {
411 INTOFF;
412 exitstatus = waitforjob(jp, (int *)NULL);
413 INTON;
414 }
415}
416
417
226 break;
227 case NSUBSHELL:
228 evalsubshell(n, flags);
229 do_etest = !(flags & EV_TESTED);
230 break;
231 case NBACKGND:
232 evalsubshell(n, flags);
233 break;

--- 174 unchanged lines hidden (view full) ---

408 } else if (! backgnd) {
409 INTOFF;
410 exitstatus = waitforjob(jp, (int *)NULL);
411 INTON;
412 }
413}
414
415
416/*
417 * Evaluate a redirected compound command.
418 */
418
419
420STATIC void
421evalredir(union node *n, int flags)
422{
423 struct jmploc jmploc;
424 struct jmploc *savehandler;
425 volatile int in_redirect = 1;
426
427 expredir(n->nredir.redirect);
428 savehandler = handler;
429 if (setjmp(jmploc.loc)) {
430 int e;
431
432 handler = savehandler;
433 e = exception;
434 if (e == EXERROR || e == EXEXEC) {
435 popredir();
436 if (in_redirect) {
437 exitstatus = 2;
438 return;
439 }
440 }
441 longjmp(handler->loc, 1);
442 } else {
443 INTOFF;
444 handler = &jmploc;
445 redirect(n->nredir.redirect, REDIR_PUSH);
446 in_redirect = 0;
447 INTON;
448 evaltree(n->nredir.n, flags);
449 }
450 INTOFF;
451 handler = savehandler;
452 popredir();
453 INTON;
454}
455
456
419/*
420 * Compute the names of the files in a redirection list.
421 */
422
423STATIC void
424expredir(union node *n)
425{
426 union node *redir;

--- 743 unchanged lines hidden ---
457/*
458 * Compute the names of the files in a redirection list.
459 */
460
461STATIC void
462expredir(union node *n)
463{
464 union node *redir;

--- 743 unchanged lines hidden ---