xref: /netbsd-src/bin/csh/init.c (revision d9158b13b5dfe46201430699a3f7a235ecf28df3)
1 /*-
2  * Copyright (c) 1980, 1991 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  * 3. All advertising materials mentioning features or use of this software
14  *    must display the following acknowledgement:
15  *	This product includes software developed by the University of
16  *	California, Berkeley and its contributors.
17  * 4. Neither the name of the University nor the names of its contributors
18  *    may be used to endorse or promote products derived from this software
19  *    without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31  * SUCH DAMAGE.
32  */
33 
34 #ifndef lint
35 /*static char sccsid[] = "from: @(#)init.c	5.12 (Berkeley) 6/27/91";*/
36 static char rcsid[] = "$Id: init.c,v 1.4 1993/08/01 19:00:39 mycroft Exp $";
37 #endif /* not lint */
38 
39 #if __STDC__
40 # include <stdarg.h>
41 #else
42 # include <varargs.h>
43 #endif
44 
45 #include "csh.h"
46 #include "extern.h"
47 
48 #define	INF	1000
49 
50 struct biltins bfunc[] =
51 {
52     "@", 	dolet, 		0, INF,
53     "alias", 	doalias, 	0, INF,
54     "alloc", 	showall, 	0, 1,
55     "bg", 	dobg, 		0, INF,
56     "break", 	dobreak, 	0, 0,
57     "breaksw", 	doswbrk, 	0, 0,
58     "case", 	dozip, 		0, 1,
59     "cd", 	dochngd, 	0, INF,
60     "chdir", 	dochngd, 	0, INF,
61     "continue", docontin, 	0, 0,
62     "default", 	dozip, 		0, 0,
63     "dirs", 	dodirs,		0, INF,
64     "echo", 	doecho,		0, INF,
65     "else", 	doelse,		0, INF,
66     "end", 	doend, 		0, 0,
67     "endif", 	dozip, 		0, 0,
68     "endsw", 	dozip, 		0, 0,
69     "eval", 	doeval, 	0, INF,
70     "exec", 	execash, 	1, INF,
71     "exit", 	doexit, 	0, INF,
72     "fg", 	dofg, 		0, INF,
73     "foreach", 	doforeach, 	3, INF,
74     "glob", 	doglob, 	0, INF,
75     "goto", 	dogoto, 	1, 1,
76     "hashstat", hashstat, 	0, 0,
77     "history", 	dohist, 	0, 2,
78     "if", 	doif, 		1, INF,
79     "jobs", 	dojobs, 	0, 1,
80     "kill", 	dokill, 	1, INF,
81     "limit", 	dolimit, 	0, 3,
82     "linedit", 	doecho, 	0, INF,
83     "login", 	dologin, 	0, 1,
84     "logout", 	dologout, 	0, 0,
85     "nice", 	donice, 	0, INF,
86     "nohup", 	donohup, 	0, INF,
87     "notify", 	donotify, 	0, INF,
88     "onintr", 	doonintr, 	0, 2,
89     "popd", 	dopopd, 	0, INF,
90     "pushd", 	dopushd, 	0, INF,
91     "rehash", 	dohash, 	0, 0,
92     "repeat", 	dorepeat, 	2, INF,
93     "set", 	doset, 		0, INF,
94     "setenv", 	dosetenv, 	0, 2,
95     "shift", 	shift, 		0, 1,
96     "source", 	dosource, 	1, 2,
97     "stop", 	dostop, 	1, INF,
98     "suspend", 	dosuspend, 	0, 0,
99     "switch", 	doswitch, 	1, INF,
100     "time", 	dotime, 	0, INF,
101     "umask", 	doumask, 	0, 1,
102     "unalias", 	unalias, 	1, INF,
103     "unhash", 	dounhash, 	0, 0,
104     "unlimit", 	dounlimit, 	0, INF,
105     "unset", 	unset, 		1, INF,
106     "unsetenv", dounsetenv, 	1, INF,
107     "wait", 	dowait, 	0, 0,
108     "while", 	dowhile, 	1, INF,
109 };
110 int     nbfunc = sizeof bfunc / sizeof *bfunc;
111 
112 struct srch srchn[] =
113 {
114     "@", 	T_LET,
115     "break", 	T_BREAK,
116     "breaksw", 	T_BRKSW,
117     "case", 	T_CASE,
118     "default", 	T_DEFAULT,
119     "else", 	T_ELSE,
120     "end", 	T_END,
121     "endif", 	T_ENDIF,
122     "endsw", 	T_ENDSW,
123     "exit", 	T_EXIT,
124     "foreach", 	T_FOREACH,
125     "goto", 	T_GOTO,
126     "if", 	T_IF,
127     "label", 	T_LABEL,
128     "set", 	T_SET,
129     "switch", 	T_SWITCH,
130     "while", 	T_WHILE,
131 };
132 int     nsrchn = sizeof srchn / sizeof *srchn;
133 
134 struct mesg mesg[] =
135 {
136      /*  0 */ 	0, 		"",
137      /*  1 */ 	"HUP", 		"Hangup",
138      /*  2 */ 	"INT", 		"Interrupt",
139      /*  3 */ 	"QUIT", 	"Quit",
140      /*  4 */ 	"ILL", 		"Illegal instruction",
141      /*  5 */ 	"TRAP", 	"Trace/BPT trap",
142      /*  6 */ 	"IOT", 		"IOT trap",
143      /*  7 */ 	"EMT", 		"EMT trap",
144      /*  8 */ 	"FPE", 		"Floating exception",
145      /*  9 */ 	"KILL", 	"Killed",
146      /* 10 */ 	"BUS", 		"Bus error",
147      /* 11 */ 	"SEGV", 	"Segmentation fault",
148      /* 12 */ 	"SYS", 		"Bad system call",
149      /* 13 */ 	"PIPE", 	"Broken pipe",
150      /* 14 */ 	"ALRM", 	"Alarm clock",
151      /* 15 */ 	"TERM", 	"Terminated",
152      /* 16 */ 	"URG", 		"Urgent condition on IO channel",
153      /* 17 */ 	"STOP", 	"Suspended (signal)",
154      /* 18 */ 	"TSTP", 	"Suspended",
155      /* 19 */ 	"CONT", 	"Continued",
156      /* 20 */ 	"CHLD", 	"Child exited",
157      /* 21 */ 	"TTIN", 	"Suspended (tty input)",
158      /* 22 */ 	"TTOU", 	"Suspended (tty output)",
159      /* 23 */ 	"IO", 		"IO possible interrupt",
160      /* 24 */ 	"XCPU", 	"Cputime limit exceeded",
161      /* 25 */ 	"XFSZ", 	"Filesize limit exceeded",
162      /* 26 */ 	"VTALRM", 	"Virtual time alarm",
163      /* 27 */ 	"PROF", 	"Profiling time alarm",
164      /* 28 */ 	"WINCH", 	"Window changed",
165      /* 29 */ 	"INFO", 	"Information request",
166      /* 30 */ 	"USR1", 	"User signal 1",
167      /* 31 */ 	"USR2", 	"User signal 2",
168      /* 32 */ 	0, 		"Signal 32",
169 };
170