BSD 3 development
[unix-history] / usr / src / cmd / csh / sh.init.c
CommitLineData
f866bfdf
BJ
1/* Copyright (c) 1979 Regents of the University of California */
2#include "sh.local.h"
3/*
4 * C shell
5 */
6
7extern int await();
8extern int chngd();
9extern int doalias();
10extern int dobreak();
11extern int docontin();
12extern int doecho();
13extern int doelse();
14extern int doend();
15extern int doendif();
16extern int doendsw();
17extern int doexit();
18extern int doforeach();
19extern int doglob();
20extern int dogoto();
21extern int dohash();
22extern int hashstat();
23extern int dohist();
24extern int doif();
25extern int dolet();
26extern int dologin();
27extern int dologout();
28extern int donewgrp();
29extern int donice();
30extern int donohup();
31extern int doonintr();
32extern int dorepeat();
33extern int doset();
34extern int dosetenv();
35extern int dosource();
36extern int doswbrk();
37extern int doswitch();
38extern int dotime();
39#ifndef V6
40extern int doumask();
41#endif
42extern int dowhile();
43extern int dozip();
44extern int execash();
45extern int goodbye();
46extern int shift();
47extern int showall();
48extern int unalias();
49extern int dounhash();
50extern int unset();
51
52#define INF 1000
53
54struct biltins {
55 char *bname;
56 int (*bfunct)();
57 short minargs, maxargs;
58} bfunc[] = {
59 "@", dolet, 0, INF,
60 "alias", doalias, 0, INF,
61#ifdef debug
62 "alloc", showall, 0, 1,
63#endif
64 "break", dobreak, 0, 0,
65 "breaksw", doswbrk, 0, 0,
66 "case", dozip, 0, 1,
67 "cd", chngd, 0, 1,
68 "chdir", chngd, 0, 1,
69 "continue", docontin, 0, 0,
70 "default", dozip, 0, 0,
71 "echo", doecho, 0, INF,
72 "else", doelse, 0, INF,
73 "end", doend, 0, 0,
74 "endif", dozip, 0, 0,
75 "endsw", dozip, 0, 0,
76 "exec", execash, 1, INF,
77 "exit", doexit, 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, 0,
83 "if", doif, 1, INF,
84 "login", dologin, 0, 1,
85 "logout", dologout, 0, 0,
86 "newgrp", donewgrp, 1, 1,
87 "nice", donice, 0, INF,
88 "nohup", donohup, 0, INF,
89 "onintr", doonintr, 0, 2,
90 "rehash", dohash, 0, 0,
91 "repeat", dorepeat, 2, INF,
92 "set", doset, 0, INF,
93#ifndef V6
94 "setenv", dosetenv, 2, 2,
95#endif
96 "shift", shift, 0, 1,
97 "source", dosource, 1, 1,
98 "switch", doswitch, 1, INF,
99 "time", dotime, 0, INF,
100#ifndef V6
101 "umask", doumask, 0, 1,
102#endif
103 "unalias", unalias, 1, INF,
104 "unhash", dounhash, 0, 0,
105 "unset", unset, 1, INF,
106 "wait", await, 0, 0,
107 "while", dowhile, 1, INF,
108 0, 0, 0, 0,
109};
110
111#define ZBREAK 0
112#define ZBRKSW 1
113#define ZCASE 2
114#define ZDEFAULT 3
115#define ZELSE 4
116#define ZEND 5
117#define ZENDIF 6
118#define ZENDSW 7
119#define ZEXIT 8
120#define ZFOREACH 9
121#define ZGOTO 10
122#define ZIF 11
123#define ZLABEL 12
124#define ZLET 13
125#define ZSET 14
126#define ZSWITCH 15
127#define ZTEST 16
128#define ZTHEN 17
129#define ZWHILE 18
130
131struct srch {
132 char *s_name;
133 short s_value;
134} srchn[] = {
135 "@", ZLET,
136 "break", ZBREAK,
137 "breaksw", ZBRKSW,
138 "case", ZCASE,
139 "default", ZDEFAULT,
140 "else", ZELSE,
141 "end", ZEND,
142 "endif", ZENDIF,
143 "endsw", ZENDSW,
144 "exit", ZEXIT,
145 "foreach", ZFOREACH,
146 "goto", ZGOTO,
147 "if", ZIF,
148 "label", ZLABEL,
149 "set", ZSET,
150 "switch", ZSWITCH,
151 "while", ZWHILE,
152 0, 0,
153};
154
155char *mesg[] = {
156 0,
157 "Hangup",
158 0,
159 "Quit",
160 "Illegal instruction",
161 "Trace/BPT trap",
162 "IOT trap",
163 "EMT trap",
164 "Floating exception",
165 "Killed",
166 "Bus error",
167 "Segmentation violation",
168 "Bad system call",
169 0,
170 "Alarm clock",
171 "Terminated",
172};