main.c (200956) | main.c (200998) |
---|---|
1/*- 2 * Copyright (c) 1991, 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 --- 28 unchanged lines hidden (view full) --- 37#endif /* not lint */ 38 39#ifndef lint 40#if 0 41static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 5/28/95"; 42#endif 43#endif /* not lint */ 44#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1991, 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 --- 28 unchanged lines hidden (view full) --- 37#endif /* not lint */ 38 39#ifndef lint 40#if 0 41static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 5/28/95"; 42#endif 43#endif /* not lint */ 44#include <sys/cdefs.h> |
45__FBSDID("$FreeBSD: head/bin/sh/main.c 200956 2009-12-24 18:41:14Z jilles $"); | 45__FBSDID("$FreeBSD: head/bin/sh/main.c 200998 2009-12-25 20:21:35Z jilles $"); |
46 47#include <stdio.h> 48#include <signal.h> 49#include <sys/stat.h> 50#include <unistd.h> 51#include <fcntl.h> 52#include <locale.h> 53#include <errno.h> --- 16 unchanged lines hidden (view full) --- 70#include "error.h" 71#include "init.h" 72#include "mystring.h" 73#include "exec.h" 74#include "cd.h" 75 76int rootpid; 77int rootshell; | 46 47#include <stdio.h> 48#include <signal.h> 49#include <sys/stat.h> 50#include <unistd.h> 51#include <fcntl.h> 52#include <locale.h> 53#include <errno.h> --- 16 unchanged lines hidden (view full) --- 70#include "error.h" 71#include "init.h" 72#include "mystring.h" 73#include "exec.h" 74#include "cd.h" 75 76int rootpid; 77int rootshell; |
78struct jmploc main_handler; |
|
78 79STATIC void read_profile(char *); 80STATIC char *find_dot_file(char *); 81 82/* 83 * Main routine. We initialize things, parse the arguments, execute 84 * profiles if we're a login shell, and then call cmdloop to execute 85 * commands. The setjmp call sets up the location to jump to when an 86 * exception occurs. When an exception occurs the variable "state" 87 * is used to figure out how far we had gotten. 88 */ 89 90int 91main(int argc, char *argv[]) 92{ | 79 80STATIC void read_profile(char *); 81STATIC char *find_dot_file(char *); 82 83/* 84 * Main routine. We initialize things, parse the arguments, execute 85 * profiles if we're a login shell, and then call cmdloop to execute 86 * commands. The setjmp call sets up the location to jump to when an 87 * exception occurs. When an exception occurs the variable "state" 88 * is used to figure out how far we had gotten. 89 */ 90 91int 92main(int argc, char *argv[]) 93{ |
93 struct jmploc jmploc; | |
94 struct stackmark smark; 95 volatile int state; 96 char *shinit; 97 98 (void) setlocale(LC_ALL, ""); 99 state = 0; | 94 struct stackmark smark; 95 volatile int state; 96 char *shinit; 97 98 (void) setlocale(LC_ALL, ""); 99 state = 0; |
100 if (setjmp(jmploc.loc)) { | 100 if (setjmp(main_handler.loc)) { |
101 /* 102 * When a shell procedure is executed, we raise the 103 * exception EXSHELLPROC to clean up before executing 104 * the shell procedure. 105 */ 106 switch (exception) { 107 case EXSHELLPROC: 108 rootpid = getpid(); --- 29 unchanged lines hidden (view full) --- 138 goto state1; 139 else if (state == 2) 140 goto state2; 141 else if (state == 3) 142 goto state3; 143 else 144 goto state4; 145 } | 101 /* 102 * When a shell procedure is executed, we raise the 103 * exception EXSHELLPROC to clean up before executing 104 * the shell procedure. 105 */ 106 switch (exception) { 107 case EXSHELLPROC: 108 rootpid = getpid(); --- 29 unchanged lines hidden (view full) --- 138 goto state1; 139 else if (state == 2) 140 goto state2; 141 else if (state == 3) 142 goto state3; 143 else 144 goto state4; 145 } |
146 handler = &jmploc; | 146 handler = &main_handler; |
147#ifdef DEBUG 148 opentrace(); 149 trputs("Shell args: "); trargs(argv); 150#endif 151 rootpid = getpid(); 152 rootshell = 1; 153 init(); 154 setstackmark(&smark); --- 194 unchanged lines hidden --- | 147#ifdef DEBUG 148 opentrace(); 149 trputs("Shell args: "); trargs(argv); 150#endif 151 rootpid = getpid(); 152 rootshell = 1; 153 init(); 154 setstackmark(&smark); --- 194 unchanged lines hidden --- |