xref: /illumos-gate/usr/src/cmd/csh/sh.init.c (revision 8ab441ef78c0aa3a5e87b38d2f5a0b5316b6da11)
1 /*
2  * Copyright 1997 Sun Microsystems, Inc.  All rights reserved.
3  * Use is subject to license terms.
4  */
5 
6 /*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
7 /*	  All Rights Reserved  	*/
8 
9 /*
10  * Copyright (c) 1980 Regents of the University of California.
11  * All rights reserved.  The Berkeley Software License Agreement
12  * specifies the terms and conditions for redistribution.
13  */
14 
15 #include "sh.h"
16 #include "sh.tconst.h"
17 
18 /*
19  * C shell
20  */
21 
22 extern	int doalias();
23 extern	int dobg();
24 extern	int dobreak();
25 extern	int dochngd();
26 extern	int docontin();
27 extern	int dodirs();
28 extern	int doecho();
29 extern	int doelse();
30 extern	int doend();
31 extern	int doendif();
32 extern	int doendsw();
33 extern	int doeval();
34 extern	int doexit();
35 extern	int dofg();
36 extern	int doforeach();
37 extern	int doglob();
38 extern	int dogoto();
39 extern	int dohash();
40 extern	int dorehash();
41 extern	int dohist();
42 extern	int doif();
43 extern	int dojobs();
44 extern	int dokill();
45 extern	int dolet();
46 extern	int dolimit();
47 extern	int dologin();
48 extern	int dologout();
49 #ifdef NEWGRP
50 extern	int donewgrp();
51 #endif
52 extern	int donice();
53 extern	int donotify();
54 extern	int donohup();
55 extern	int doonintr();
56 extern	int dopopd();
57 extern	int dopushd();
58 extern	int dorepeat();
59 extern	int doset();
60 extern	int dosetenv();
61 extern	int dosource();
62 extern	int dostop();
63 extern	int dosuspend();
64 extern	int doswbrk();
65 extern	int doswitch();
66 extern	int dotime();
67 extern	int dounlimit();
68 extern	int doumask();
69 extern	int dowait();
70 extern	int dowhile();
71 extern	int dozip();
72 extern	int execash();
73 extern	int goodbye();
74 #ifdef VFORK
75 extern	int hashstat();
76 #endif
77 extern	int shift();
78 #ifdef OLDMALLOC
79 extern	int showall();
80 #endif
81 extern	int unalias();
82 extern	int dounhash();
83 extern	int unset();
84 extern	int dounsetenv();
85 
86 #define	INF	1000
87 
88 struct	biltins bfunc[] = {
89 	S_AT,		dolet,		0,	INF,
90 	S_alias,	doalias,	0,	INF,
91 #ifdef OLDMALLOC
92 	S_alloc,	showall,	0,	1,
93 #endif
94 	S_bg,		dobg,		0,	INF,
95 	S_break,	dobreak,	0,	0,
96 	S_breaksw,	doswbrk,	0,	0,
97 #ifdef IIASA
98 	S_bye,		goodbye,	0,	0,
99 #endif
100 	S_case,	dozip,		0,	1,
101 	S_cd,		dochngd,	0,	1,
102 	S_chdir,	dochngd,	0,	1,
103 	S_continue,	docontin,	0,	0,
104 	S_default,	dozip,		0,	0,
105 	S_dirs,	dodirs,		0,	1,
106 	S_echo,	doecho,		0,	INF,
107 	S_else,	doelse,		0,	INF,
108 	S_end,		doend,		0,	0,
109 	S_endif,	dozip,		0,	0,
110 	S_endsw,	dozip,		0,	0,
111 	S_eval,	doeval,		0,	INF,
112 	S_exec,	execash,	1,	INF,
113 	S_exit,	doexit,		0,	INF,
114 	S_fg,		dofg,		0,	INF,
115 	S_foreach,	doforeach,	3,	INF,
116 #ifdef IIASA
117 	S_gd,		dopushd,	0,	1,
118 #endif
119 	S_glob,	doglob,		0,	INF,
120 	S_goto,	dogoto,		1,	1,
121 #ifdef VFORK
122 	S_hashstat,	hashstat,	0,	0,
123 #endif
124 	S_history,	dohist,		0,	2,
125 	S_if,		doif,		1,	INF,
126 	S_jobs,	dojobs,		0,	1,
127 	S_kill,	dokill,		1,	INF,
128 	S_limit,	dolimit,	0,	3,
129 	S_login,	dologin,	0,	1,
130 	S_logout,	dologout,	0,	0,
131 #ifdef NEWGRP
132 	S_newgrp,	donewgrp,	1,	1,
133 #endif
134 	S_nice,	donice,		0,	INF,
135 	S_nohup,	donohup,	0,	INF,
136 	S_notify,	donotify,	0,	INF,
137 	S_onintr,	doonintr,	0,	2,
138 	S_popd,	dopopd,		0,	1,
139 	S_pushd,	dopushd,	0,	1,
140 #ifdef IIASA
141 	S_rd,		dopopd,		0,	1,
142 #endif
143 	S_rehash,	dorehash,	0,	0,
144 	S_repeat,	dorepeat,	2,	INF,
145 	S_set,		doset,		0,	INF,
146 	S_setenv,	dosetenv,	0,	2,
147 	S_shift,	shift,		0,	1,
148 	S_source,	dosource,	1,	2,
149 	S_stop,	dostop,		1,	INF,
150 	S_suspend,	dosuspend,	0,	0,
151 	S_switch,	doswitch,	1,	INF,
152 	S_time,		dotime,		0,	INF,
153 	S_umask,	doumask,	0,	1,
154 	S_unalias,	unalias,	1,	INF,
155 	S_unhash,	dounhash,	0,	0,
156 	S_unlimit,	dounlimit,	0,	INF,
157 	S_unset,	unset,		1,	INF,
158 	S_unsetenv,	dounsetenv,	1,	INF,
159 	S_wait,		dowait,		0,	0,
160 	S_while,	dowhile,	1,	INF,
161 };
162 int nbfunc = sizeof bfunc / sizeof *bfunc;
163 
164 #define	ZBREAK		0
165 #define	ZBRKSW		1
166 #define	ZCASE		2
167 #define	ZDEFAULT 	3
168 #define	ZELSE		4
169 #define	ZEND		5
170 #define	ZENDIF		6
171 #define	ZENDSW		7
172 #define	ZEXIT		8
173 #define	ZFOREACH	9
174 #define	ZGOTO		10
175 #define	ZIF		11
176 #define	ZLABEL		12
177 #define	ZLET		13
178 #define	ZSET		14
179 #define	ZSWITCH		15
180 #define	ZTEST		16
181 #define	ZTHEN		17
182 #define	ZWHILE		18
183 
184 struct srch srchn[] = {
185 	S_AT,		ZLET,
186 	S_break,	ZBREAK,
187 	S_breaksw,	ZBRKSW,
188 	S_case,		ZCASE,
189 	S_default, 	ZDEFAULT,
190 	S_else,		ZELSE,
191 	S_end,		ZEND,
192 	S_endif,	ZENDIF,
193 	S_endsw,	ZENDSW,
194 	S_exit,		ZEXIT,
195 	S_foreach, 	ZFOREACH,
196 	S_goto,		ZGOTO,
197 	S_if,		ZIF,
198 	S_label,	ZLABEL,
199 	S_set,		ZSET,
200 	S_switch,	ZSWITCH,
201 	S_while,	ZWHILE
202 };
203 int nsrchn = sizeof srchn / sizeof *srchn;
204 
205