init.c revision 1.6 1 /* $NetBSD: init.c,v 1.6 1995/03/21 09:03:05 cgd Exp $ */
2
3 /*-
4 * Copyright (c) 1980, 1991, 1993
5 * The Regents of the University of California. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by the University of
18 * California, Berkeley and its contributors.
19 * 4. Neither the name of the University nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 */
35
36 #ifndef lint
37 #if 0
38 static char sccsid[] = "@(#)init.c 8.1 (Berkeley) 5/31/93";
39 #else
40 static char rcsid[] = "$NetBSD: init.c,v 1.6 1995/03/21 09:03:05 cgd Exp $";
41 #endif
42 #endif /* not lint */
43
44 #if __STDC__
45 # include <stdarg.h>
46 #else
47 # include <varargs.h>
48 #endif
49
50 #include "csh.h"
51 #include "extern.h"
52
53 #define INF 1000
54
55 struct biltins bfunc[] =
56 {
57 { "@", dolet, 0, INF },
58 { "alias", doalias, 0, INF },
59 { "alloc", showall, 0, 1 },
60 { "bg", dobg, 0, INF },
61 { "break", dobreak, 0, 0 },
62 { "breaksw", doswbrk, 0, 0 },
63 { "case", dozip, 0, 1 },
64 { "cd", dochngd, 0, INF },
65 { "chdir", dochngd, 0, INF },
66 { "continue", docontin, 0, 0 },
67 { "default", dozip, 0, 0 },
68 { "dirs", dodirs, 0, INF },
69 { "echo", doecho, 0, INF },
70 { "else", doelse, 0, INF },
71 { "end", doend, 0, 0 },
72 { "endif", dozip, 0, 0 },
73 { "endsw", dozip, 0, 0 },
74 { "eval", doeval, 0, INF },
75 { "exec", execash, 1, INF },
76 { "exit", doexit, 0, INF },
77 { "fg", dofg, 0, INF },
78 { "foreach", doforeach, 3, INF },
79 { "glob", doglob, 0, INF },
80 { "goto", dogoto, 1, 1 },
81 { "hashstat", hashstat, 0, 0 },
82 { "history", dohist, 0, 2 },
83 { "if", doif, 1, INF },
84 { "jobs", dojobs, 0, 1 },
85 { "kill", dokill, 1, INF },
86 { "limit", dolimit, 0, 3 },
87 { "linedit", doecho, 0, INF },
88 { "login", dologin, 0, 1 },
89 { "logout", dologout, 0, 0 },
90 { "nice", donice, 0, INF },
91 { "nohup", donohup, 0, INF },
92 { "notify", donotify, 0, INF },
93 { "onintr", doonintr, 0, 2 },
94 { "popd", dopopd, 0, INF },
95 { "printf", doprintf, 1, INF },
96 { "pushd", dopushd, 0, INF },
97 { "rehash", dohash, 0, 0 },
98 { "repeat", dorepeat, 2, INF },
99 { "set", doset, 0, INF },
100 { "setenv", dosetenv, 0, 2 },
101 { "shift", shift, 0, 1 },
102 { "source", dosource, 1, 2 },
103 { "stop", dostop, 1, INF },
104 { "suspend", dosuspend, 0, 0 },
105 { "switch", doswitch, 1, INF },
106 { "time", dotime, 0, INF },
107 { "umask", doumask, 0, 1 },
108 { "unalias", unalias, 1, INF },
109 { "unhash", dounhash, 0, 0 },
110 { "unlimit", dounlimit, 0, INF },
111 { "unset", unset, 1, INF },
112 { "unsetenv", dounsetenv, 1, INF },
113 { "wait", dowait, 0, 0 },
114 { "which", dowhich, 1, INF },
115 { "while", dowhile, 1, INF }
116 };
117 int nbfunc = sizeof bfunc / sizeof *bfunc;
118
119 struct srch srchn[] =
120 {
121 { "@", T_LET },
122 { "break", T_BREAK },
123 { "breaksw", T_BRKSW },
124 { "case", T_CASE },
125 { "default", T_DEFAULT },
126 { "else", T_ELSE },
127 { "end", T_END },
128 { "endif", T_ENDIF },
129 { "endsw", T_ENDSW },
130 { "exit", T_EXIT },
131 { "foreach", T_FOREACH },
132 { "goto", T_GOTO },
133 { "if", T_IF },
134 { "label", T_LABEL },
135 { "set", T_SET },
136 { "switch", T_SWITCH },
137 { "while", T_WHILE }
138 };
139 int nsrchn = sizeof srchn / sizeof *srchn;
140
141