xref: /netbsd/bin/csh/init.c (revision bf9ec67e)
1 /* $NetBSD: init.c,v 1.9 2002/05/25 23:29:16 wiz 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 #include <sys/cdefs.h>
37 #ifndef lint
38 #if 0
39 static char sccsid[] = "@(#)init.c	8.1 (Berkeley) 5/31/93";
40 #else
41 __RCSID("$NetBSD: init.c,v 1.9 2002/05/25 23:29:16 wiz Exp $");
42 #endif
43 #endif /* not lint */
44 
45 #include <stdarg.h>
46 
47 #include "csh.h"
48 #include "extern.h"
49 
50 #define	INF	1000
51 
52 struct biltins bfunc[] =
53 {
54     { "@", 		dolet, 		0, INF	},
55     { "alias", 		doalias, 	0, INF	},
56     { "alloc", 		showall, 	0, 1	},
57     { "bg", 		dobg, 		0, INF	},
58     { "break", 		dobreak, 	0, 0	},
59     { "breaksw", 	doswbrk, 	0, 0	},
60     { "case", 		dozip, 		0, 1	},
61     { "cd", 		dochngd, 	0, INF	},
62     { "chdir", 		dochngd, 	0, INF	},
63     { "continue", 	docontin, 	0, 0	},
64     { "default", 	dozip, 		0, 0	},
65     { "dirs", 		dodirs,		0, INF	},
66     { "echo", 		doecho,		0, INF	},
67     { "else", 		doelse,		0, INF	},
68     { "end", 		doend, 		0, 0	},
69     { "endif", 		dozip, 		0, 0	},
70     { "endsw", 		dozip, 		0, 0	},
71     { "eval", 		doeval, 	0, INF	},
72     { "exec", 		execash, 	1, INF	},
73     { "exit", 		doexit, 	0, INF	},
74     { "fg", 		dofg, 		0, INF	},
75     { "foreach", 	doforeach, 	3, INF	},
76     { "glob", 		doglob, 	0, INF	},
77     { "goto", 		dogoto, 	1, 1	},
78     { "hashstat", 	hashstat, 	0, 0	},
79     { "history", 	dohist, 	0, 2	},
80     { "if", 		doif, 		1, INF	},
81     { "jobs", 		dojobs, 	0, 1	},
82     { "kill", 		dokill, 	1, INF	},
83     { "limit", 		dolimit, 	0, 3	},
84     { "linedit", 	doecho, 	0, INF	},
85     { "login", 		dologin, 	0, 1	},
86     { "logout", 	dologout, 	0, 0	},
87     { "nice", 		donice, 	0, INF	},
88     { "nohup", 		donohup, 	0, INF	},
89     { "notify", 	donotify, 	0, INF	},
90     { "onintr", 	doonintr, 	0, 2	},
91     { "popd", 		dopopd, 	0, INF	},
92     { "printf",		doprintf,	1, INF	},
93     { "pushd", 		dopushd, 	0, INF	},
94     { "rehash", 	dohash, 	0, 0	},
95     { "repeat", 	dorepeat, 	2, INF	},
96     { "set", 		doset, 		0, INF	},
97     { "setenv", 	dosetenv, 	0, 2	},
98     { "shift", 		shift, 		0, 1	},
99     { "source", 	dosource, 	1, 2	},
100     { "stop", 		dostop, 	1, INF	},
101     { "suspend", 	dosuspend, 	0, 0	},
102     { "switch", 	doswitch, 	1, INF	},
103     { "time", 		dotime, 	0, INF	},
104     { "umask", 		doumask, 	0, 1	},
105     { "unalias", 	unalias, 	1, INF	},
106     { "unhash", 	dounhash, 	0, 0	},
107     { "unlimit", 	dounlimit, 	0, INF	},
108     { "unset", 		unset, 		1, INF	},
109     { "unsetenv", 	dounsetenv, 	1, INF	},
110     { "wait",		dowait, 	0, 0	},
111     { "which",		dowhich, 	1, INF	},
112     { "while", 		dowhile, 	1, INF	}
113 };
114 int nbfunc = sizeof(bfunc) / sizeof(*bfunc);
115 
116 struct srch srchn[] =
117 {
118     { "@", 		T_LET		},
119     { "break", 		T_BREAK		},
120     { "breaksw", 	T_BRKSW		},
121     { "case", 		T_CASE		},
122     { "default", 	T_DEFAULT	},
123     { "else", 		T_ELSE		},
124     { "end", 		T_END		},
125     { "endif", 		T_ENDIF		},
126     { "endsw", 		T_ENDSW		},
127     { "exit", 		T_EXIT		},
128     { "foreach", 	T_FOREACH	},
129     { "goto", 		T_GOTO		},
130     { "if", 		T_IF		},
131     { "label", 		T_LABEL		},
132     { "set", 		T_SET		},
133     { "switch", 	T_SWITCH	},
134     { "while", 		T_WHILE		}
135 };
136 int nsrchn = sizeof(srchn) / sizeof(*srchn);
137