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