xref: /original-bsd/bin/csh/init.c (revision 95a66346)
1 /*
2  * Copyright (c) 1980 Regents of the University of California.
3  * All rights reserved.  The Berkeley Software License Agreement
4  * specifies the terms and conditions for redistribution.
5  */
6 
7 #ifndef lint
8 static char *sccsid = "@(#)init.c	5.5 (Berkeley) 03/18/91";
9 #endif
10 
11 #include "sh.h"
12 
13 /*
14  * C shell
15  */
16 
17 extern	int doalias();
18 extern	int dobg();
19 extern	int dobreak();
20 extern	int dochngd();
21 extern	int docontin();
22 extern	int dodirs();
23 extern	int doecho();
24 extern	int doelse();
25 extern	int doend();
26 extern	int doendif();
27 extern	int doendsw();
28 extern	int doeval();
29 extern	int doexit();
30 extern	int dofg();
31 extern	int doforeach();
32 extern	int doglob();
33 extern	int dogoto();
34 extern	int dohash();
35 extern	int dohist();
36 extern	int doif();
37 extern	int dojobs();
38 extern	int dokill();
39 extern	int dolet();
40 extern	int dolimit();
41 extern	int dologin();
42 extern	int dologout();
43 extern	int donice();
44 extern	int donotify();
45 extern	int donohup();
46 extern	int doonintr();
47 extern	int dopopd();
48 extern	int dopushd();
49 extern	int dorepeat();
50 extern	int doset();
51 extern	int dosetenv();
52 extern	int dosource();
53 extern	int dostop();
54 extern	int dosuspend();
55 extern	int doswbrk();
56 extern	int doswitch();
57 extern	int dotime();
58 extern	int dounlimit();
59 extern	int doumask();
60 extern	int dowait();
61 extern	int dowhile();
62 extern	int dozip();
63 extern	int execash();
64 extern	int goodbye();
65 #ifdef VFORK
66 extern	int hashstat();
67 #endif
68 extern	int shift();
69 extern	int showall();
70 extern	int unalias();
71 extern	int dounhash();
72 extern	int unset();
73 extern	int dounsetenv();
74 
75 #define	INF	1000
76 
77 struct biltins bfunc[] = {
78 	"@",		dolet,		0,	INF,
79 	"alias",	doalias,	0,	INF,
80 	"alloc",	showall,	0,	1,
81 	"bg",		dobg,		0,	INF,
82 	"break",	dobreak,	0,	0,
83 	"breaksw",	doswbrk,	0,	0,
84 	"case",		dozip,		0,	1,
85 	"cd",		dochngd,	0,	1,
86 	"chdir",	dochngd,	0,	1,
87 	"continue",	docontin,	0,	0,
88 	"default",	dozip,		0,	0,
89 	"dirs",		dodirs,		0,	1,
90 	"echo",		doecho,		0,	INF,
91 	"else",		doelse,		0,	INF,
92 	"end",		doend,		0,	0,
93 	"endif",	dozip,		0,	0,
94 	"endsw",	dozip,		0,	0,
95 	"eval",		doeval,		0,	INF,
96 	"exec",		execash,	1,	INF,
97 	"exit",		doexit,		0,	INF,
98 	"fg",		dofg,		0,	INF,
99 	"foreach",	doforeach,	3,	INF,
100 	"glob",		doglob,		0,	INF,
101 	"goto",		dogoto,		1,	1,
102 #ifdef VFORK
103 	"hashstat",	hashstat,	0,	0,
104 #endif
105 	"history",	dohist,		0,	2,
106 	"if",		doif,		1,	INF,
107 	"jobs",		dojobs,		0,	1,
108 	"kill",		dokill,		1,	INF,
109 	"limit",	dolimit,	0,	3,
110 	"login",	dologin,	0,	1,
111 	"logout",	dologout,	0,	0,
112 	"nice",		donice,		0,	INF,
113 	"nohup",	donohup,	0,	INF,
114 	"notify",	donotify,	0,	INF,
115 	"onintr",	doonintr,	0,	2,
116 	"popd",		dopopd,		0,	1,
117 	"pushd",	dopushd,	0,	1,
118 	"rehash",	dohash,		0,	0,
119 	"repeat",	dorepeat,	2,	INF,
120 	"set",		doset,		0,	INF,
121 	"setenv",	dosetenv,	0,	2,
122 	"shift",	shift,		0,	1,
123 	"source",	dosource,	1,	2,
124 	"stop",		dostop,		1,	INF,
125 	"suspend",	dosuspend,	0,	0,
126 	"switch",	doswitch,	1,	INF,
127 	"time",		dotime,		0,	INF,
128 	"umask",	doumask,	0,	1,
129 	"unalias",	unalias,	1,	INF,
130 	"unhash",	dounhash,	0,	0,
131 	"unlimit",	dounlimit,	0,	INF,
132 	"unset",	unset,		1,	INF,
133 	"unsetenv",	dounsetenv,	1,	INF,
134 	"wait",		dowait,		0,	0,
135 	"while",	dowhile,	1,	INF,
136 };
137 int nbfunc = sizeof bfunc / sizeof *bfunc;
138 
139 struct srch srchn[] = {
140 	"@",		ZLET,
141 	"break",	ZBREAK,
142 	"breaksw",	ZBRKSW,
143 	"case",		ZCASE,
144 	"default", 	ZDEFAULT,
145 	"else",		ZELSE,
146 	"end",		ZEND,
147 	"endif",	ZENDIF,
148 	"endsw",	ZENDSW,
149 	"exit",		ZEXIT,
150 	"foreach", 	ZFOREACH,
151 	"goto",		ZGOTO,
152 	"if",		ZIF,
153 	"label",	ZLABEL,
154 	"set",		ZSET,
155 	"switch",	ZSWITCH,
156 	"while",	ZWHILE,
157 };
158 int nsrchn = sizeof srchn / sizeof *srchn;
159 
160 struct mesg mesg[] = {
161 	0,	0,
162 	"HUP",	"Hangup",
163 	"INT",	"Interrupt",
164 	"QUIT",	"Quit",
165 	"ILL",	"Illegal instruction",
166 	"TRAP",	"Trace/BPT trap",
167 	"IOT",	"IOT trap",
168 	"EMT",	"EMT trap",
169 	"FPE",	"Floating exception",
170 	"KILL",	"Killed",
171 	"BUS",	"Bus error",
172 	"SEGV",	"Segmentation fault",
173 	"SYS",	"Bad system call",
174 	"PIPE",	"Broken pipe",
175 	"ALRM",	"Alarm clock",
176 	"TERM",	"Terminated",
177 	"URG",	"Urgent I/O condition",
178 	"STOP",	"Suspended (signal)",
179 	"TSTP",	"Suspended",
180 	"CONT",	"Continued",
181 	"CHLD",	"Child exited",
182 	"TTIN", "Suspended (tty input)",
183 	"TTOU", "Suspended (tty output)",
184 	"IO",	"I/O possible",
185 	"XCPU",	"Cputime limit exceeded",
186 	"XFSZ", "Filesize limit exceeded",
187 	"VTALRM","Virtual timer expired",
188 	"PROF",	"Profiling timer expired",
189 	"WINCH","Window size changed",
190 	0,	"Signal 29",
191 	"USR1",	"User defined signal 1",
192 	"USR2",	"User defined signal 2",
193 	0,	"Signal 32"
194 };
195