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