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