xref: /csrg-svn/local/toolchest/ksh/sh/msg.c (revision 35156)
1*35156Smarc /* @(#)msg.c	1.1 */
2*35156Smarc /*
3*35156Smarc  *	UNIX shell
4*35156Smarc  *	S. R. Bourne
5*35156Smarc  *	Rewritten by David Korn
6*35156Smarc  *
7*35156Smarc  *	AT&T Bell Laboratories
8*35156Smarc  *
9*35156Smarc  */
10*35156Smarc 
11*35156Smarc 
12*35156Smarc #include	<errno.h>
13*35156Smarc #include	"flags.h"
14*35156Smarc #include	"name.h"
15*35156Smarc #include	"defs.h"
16*35156Smarc #include	"sym.h"
17*35156Smarc #include	"builtins.h"
18*35156Smarc #include	"brkincr.h"
19*35156Smarc #include	"test.h"
20*35156Smarc #include	"timeout.h"
21*35156Smarc #include	"history.h"
22*35156Smarc 
23*35156Smarc #ifdef MULTIBYTE
24*35156Smarc #include	"national.h"
25*35156Smarc const MSG version 	= "@(#)Version M-06/03/86a";
26*35156Smarc 
27*35156Smarc #else
28*35156Smarc const MSG version 	= "@(#)Version 06/03/86a";
29*35156Smarc #endif /* MULTIBYTE */
30*35156Smarc 
31*35156Smarc extern struct Bfunction randnum;
32*35156Smarc extern struct Bfunction seconds;
33*35156Smarc 
34*35156Smarc /* error messages */
35*35156Smarc const MSG	time_warn	= "\r\n\007shell time out in 60 seconds";
36*35156Smarc const MSG	timed_out	= "timed out waiting for input";
37*35156Smarc const MSG	recursive	= "recursive call";
38*35156Smarc const MSG	noquery		= "no query process";
39*35156Smarc const MSG	nohistory	= "no history file";
40*35156Smarc const MSG	badopt		= "bad option(s)";
41*35156Smarc const MSG	mailmsg		= "you have mail in $_";
42*35156Smarc const MSG	nospace		= "no space";
43*35156Smarc const MSG	synmsg		= "syntax error";
44*35156Smarc 
45*35156Smarc const MSG	parexp		= ") expected";
46*35156Smarc const MSG	argexp		= "argument expected";
47*35156Smarc const MSG	endmatch	= "] missing";
48*35156Smarc const MSG	badnum		= "bad number";
49*35156Smarc const MSG	badcooked	= "cannot reset tty to cooked mode";
50*35156Smarc const MSG	badparam	= "parameter null or not set";
51*35156Smarc const MSG	unset		= "parameter not set";
52*35156Smarc const MSG	badsub		= "bad substitution";
53*35156Smarc const MSG	badcreate	= "cannot create";
54*35156Smarc const MSG	restricted	= "restricted";
55*35156Smarc const MSG	nofork		= "cannot fork: too many processes";
56*35156Smarc const MSG	pexists		= "process already exists";
57*35156Smarc const MSG	noswap		= "cannot fork: no swap space";
58*35156Smarc const MSG	piperr		= "cannot make pipe";
59*35156Smarc const MSG	logout		= "Use 'exit' to logout";
60*35156Smarc const MSG	badopen		= "cannot open";
61*35156Smarc const MSG	coredump	= " - core dumped";
62*35156Smarc const MSG	ptrace		= "ptrace: ";
63*35156Smarc const MSG	arglist		= "arg list too long";
64*35156Smarc const MSG	txtbsy		= "text busy";
65*35156Smarc const MSG	toobig		= "too big";
66*35156Smarc const MSG	badexec		= "cannot execute";
67*35156Smarc const MSG	pwderr		= "cannot access parent directories";
68*35156Smarc const MSG	notfound	= " not found";
69*35156Smarc const MSG	nomorefiles	= "too many open files";
70*35156Smarc #ifdef ELIBACC
71*35156Smarc /* shared library error messages */
72*35156Smarc const MSG	libacc 		= "can't access a needed shared library";
73*35156Smarc const MSG	libbad		= "accessing a corrupted shared library";
74*35156Smarc const MSG	libscn		= ".lib section in a.out corrupted";
75*35156Smarc const MSG	libmax		= "attempting to link in too many libs";
76*35156Smarc #endif	/* ELIBACC */
77*35156Smarc const MSG	badfile		= "bad file unit number";
78*35156Smarc const MSG	baddir		= "bad directory";
79*35156Smarc const MSG	badtrap		= "bad trap";
80*35156Smarc const MSG	wtfailed	= "is read only";
81*35156Smarc const MSG	notid		= "invalid identifier";
82*35156Smarc const MSG	badop		= "unknown test operator";
83*35156Smarc const MSG	noalias		= " alias not found";
84*35156Smarc const MSG	is_reserved	= " is a reserved word";
85*35156Smarc const MSG	is_builtin	= " is a shell builtin";
86*35156Smarc const MSG	is_alias	= " is an alias for ";
87*35156Smarc const MSG	is_function	= " is a function";
88*35156Smarc const MSG	is_xalias	= " is an exported alias for ";
89*35156Smarc const MSG	is_talias	= " is a tracked alias for ";
90*35156Smarc const MSG	is_xfunction	= " is an exported function";
91*35156Smarc const MSG	is_		= " is ";
92*35156Smarc const MSG	on_		= "on";
93*35156Smarc const MSG	off_		= "off";
94*35156Smarc const MSG	divzero		= "division by zero";
95*35156Smarc const MSG	subscript	= "subscript out of range";
96*35156Smarc const MSG	argcount	= "bad argument count";
97*35156Smarc const MSG	fn_hdr		= "\n{\n";
98*35156Smarc #ifdef VSH
99*35156Smarc const MSG	big_vi		= "fc -e \"${VISUAL:-${EDITOR:-vi}}\" ";
100*35156Smarc #endif
101*35156Smarc #ifdef JOBS
102*35156Smarc #ifdef BSD
103*35156Smarc const MSG	j_not_tty	= "Warning: no access to tty; thus no job control in this shell...\n";
104*35156Smarc const MSG	j_newtty	= "Switching to new tty driver...\n";
105*35156Smarc const MSG	j_oldtty	= "Reverting to old tty driver...\n";
106*35156Smarc const MSG	j_no_start	= "Cannot start job control\n";
107*35156Smarc #endif
108*35156Smarc const MSG	j_Done		= " Done";
109*35156Smarc const MSG	j_amp		= " &\n";
110*35156Smarc const MSG	j_cpid		= "|&\n";
111*35156Smarc const MSG	j_space		= "|\n      ";
112*35156Smarc const MSG	j_Running	= " Running";
113*35156Smarc const MSG	j_coredump	= "(coredump)";
114*35156Smarc const MSG	j_terminate	= "You have stopped jobs\n";
115*35156Smarc const MSG	j_running	= "You have running jobs\n";
116*35156Smarc const MSG	j_no_job	= "No such job";
117*35156Smarc const MSG	j_no_proc	= "No such process";
118*35156Smarc const MSG	j_perm		= "Permission denied";
119*35156Smarc const MSG	j_kill		= "kill: ";
120*35156Smarc const MSG	kill_usage	= "Arguments should be jobs or process ids";
121*35156Smarc const MSG	j_no_jctl	= "No job control";
122*35156Smarc #endif
123*35156Smarc #ifdef DEVFD
124*35156Smarc const MSG	devfd		= "/dev/fd/";
125*35156Smarc #endif
126*35156Smarc 
127*35156Smarc /* string constants */
128*35156Smarc const MSG	test_opts	= "rwxdcbfugkLpsnzt";
129*35156Smarc const MSG	opt_heading	= "Current option settings";
130*35156Smarc const MSG	nullstr		= "";
131*35156Smarc const MSG	sptbnl		= " \t\n";
132*35156Smarc const MSG	defpath		= "/bin:/usr/bin:";
133*35156Smarc const MSG	defedit		= "/bin/ed";
134*35156Smarc const MSG	colon		= ": ";
135*35156Smarc const MSG	minus		= "-";
136*35156Smarc const MSG	endoffile	= "end of file";
137*35156Smarc const MSG	unexpected 	= " unexpected";
138*35156Smarc const MSG	unmatched 	= " unmatched";
139*35156Smarc const MSG	unknown 	= "<job name unknown>";
140*35156Smarc const MSG	let_syntax	= "arithmetic expression ending in single ')' ";
141*35156Smarc const MSG	atline		= " at line ";
142*35156Smarc const MSG	devnull		= "/dev/null";
143*35156Smarc const MSG	execpmsg	= "+ ";
144*35156Smarc const MSG	supprompt	= "# ";
145*35156Smarc const MSG	stdprompt	= "$ ";
146*35156Smarc const MSG	profile		= "${HOME:-.}/.profile";
147*35156Smarc const MSG	sysprofile	= "/etc/profile";
148*35156Smarc const MSG	suid_profile	= "/etc/suid_profile";
149*35156Smarc #ifdef BSD_4_2
150*35156Smarc const MSG	prohibited	= "login setuid/setgid shells prohibited";
151*35156Smarc #endif /* BSD_4_2 */
152*35156Smarc #ifdef SUID_EXEC
153*35156Smarc const MSG	suid_exec	= "/etc/suid_exec";
154*35156Smarc const MSG	devfdNN		= "/dev/fd/??";
155*35156Smarc #endif /* SUID_EXEC */
156*35156Smarc const MSG	histfname	= "/.sh_history";
157*35156Smarc const MSG	unlimited	= "unlimited";
158*35156Smarc #ifdef ECHO_N
159*35156Smarc const MSG	echo_bin	= "/bin/echo";
160*35156Smarc const MSG	echo_opt	= "-R";
161*35156Smarc #endif	/* ECHO_N */
162*35156Smarc const MSG	btest		= "test";
163*35156Smarc const MSG	bkill		= "kill";
164*35156Smarc const MSG	bset		= "set";
165*35156Smarc const MSG	blet		= "let";
166*35156Smarc const MSG	bread		= "read";
167*35156Smarc const MSG	dot		= ".";
168*35156Smarc const MSG	bltfn		= "function ";
169*35156Smarc const MSG	intbase		= "base";
170*35156Smarc const MSG	setpwd		= "PWD=`/bin/pwd 2>/dev/null`";
171*35156Smarc const MSG	t_real		= "\nreal";
172*35156Smarc const MSG	t_user		= "user";
173*35156Smarc const MSG	t_sys		= "sys";
174*35156Smarc 
175*35156Smarc #ifdef apollo
176*35156Smarc #undef NULL
177*35156Smarc #define NULL ""
178*35156Smarc #define nullstr	""
179*35156Smarc #endif	/* apollo */
180*35156Smarc 
181*35156Smarc /* built in names */ struct name_value node_names[] =
182*35156Smarc {
183*35156Smarc 	"PATH",		NULL,
184*35156Smarc 	"PS1",		NULL,
185*35156Smarc 	"PS2",		"> ",
186*35156Smarc #ifdef apollo
187*35156Smarc 	"IFS",		" \t\n",
188*35156Smarc #else
189*35156Smarc 	"IFS",		sptbnl,
190*35156Smarc #endif	/* apollo */
191*35156Smarc 	"PWD",		NULL,
192*35156Smarc 	"HOME",		NULL,
193*35156Smarc 	"MAIL",		NULL,
194*35156Smarc 	"REPLY",	NULL,
195*35156Smarc 	"SHELL",	"/bin/sh",
196*35156Smarc 	"EDITOR",	"/bin/ed",
197*35156Smarc #ifdef apollo
198*35156Smarc 	"MAILCHECK",	NULL,
199*35156Smarc 	"RANDOM",	NULL,
200*35156Smarc #else
201*35156Smarc 	"MAILCHECK",	(char*)(&mailchk),
202*35156Smarc 	"RANDOM",	(char*)(&randnum),
203*35156Smarc #endif	/* apollo */
204*35156Smarc 	"ENV",		NULL,
205*35156Smarc 	"HISTFILE",	NULL,
206*35156Smarc 	"HISTSIZE",	NULL,
207*35156Smarc 	"FCEDIT",	"/bin/ed",
208*35156Smarc 	"CDPATH",	NULL,
209*35156Smarc 	"MAILPATH",	NULL,
210*35156Smarc 	"PS3",		"#? ",
211*35156Smarc 	"OLDPWD",	NULL,
212*35156Smarc 	"VISUAL",	NULL,
213*35156Smarc 	"COLUMNS",	NULL,
214*35156Smarc 	"LINES",	NULL,
215*35156Smarc #ifdef apollo
216*35156Smarc 	"PPID",		NULL,
217*35156Smarc 	"_",		NULL,
218*35156Smarc 	"TMOUT",	NULL,
219*35156Smarc 	"SECONDS",	NULL,
220*35156Smarc #else
221*35156Smarc 	"PPID",		(char*)(&ppid),
222*35156Smarc 	"_",		(char*)(&lastarg),
223*35156Smarc 	"TMOUT",	(char*)(&timeout),
224*35156Smarc 	"SECONDS",	(char*)(&seconds),
225*35156Smarc #endif	/* apollo */
226*35156Smarc #ifdef ACCT
227*35156Smarc 	"SHACCT",	NULL,
228*35156Smarc #endif	/* ACCT */
229*35156Smarc 	nullstr,	NULL
230*35156Smarc };
231*35156Smarc 
232*35156Smarc 
233*35156Smarc /* built in aliases - automatically exported */
234*35156Smarc struct name_value alias_names[] =
235*35156Smarc {
236*35156Smarc 	"cat",		"/bin/cat",
237*35156Smarc 	"chmod",	"/bin/chmod",
238*35156Smarc 	"cc",		"/bin/cc",
239*35156Smarc 	"cp",		"/bin/cp",
240*35156Smarc 	"date",		"/bin/date",
241*35156Smarc 	"ed",		"/bin/ed",
242*35156Smarc 	"false",	"let 0",
243*35156Smarc 	"functions",	"typeset -f",
244*35156Smarc #ifdef BSD
245*35156Smarc 	"grep",		"/usr/ucb/grep",
246*35156Smarc #else
247*35156Smarc 	"grep",		"/bin/grep",
248*35156Smarc #endif	/* BSD */
249*35156Smarc 	"hash",		"alias -t",
250*35156Smarc 	"history",	"fc -l",
251*35156Smarc 	"integer",	"typeset -i",
252*35156Smarc 	"lpr",		"/usr/bin/lpr",
253*35156Smarc 	"ls",		"/bin/ls",
254*35156Smarc 	"make",		"/bin/make",
255*35156Smarc 	"mail",		"/bin/mail",
256*35156Smarc 	"mv",		"/bin/mv",
257*35156Smarc 	"nohup",	"nohup ",
258*35156Smarc 	"pr",		"/bin/pr",
259*35156Smarc 	"r",		"fc -e -",
260*35156Smarc 	"rm",		"/bin/rm",
261*35156Smarc 	"sed",		"/bin/sed",
262*35156Smarc 	"sh",		"/bin/sh",
263*35156Smarc 	"true",		":",
264*35156Smarc 	"type",		"whence -v",
265*35156Smarc #ifdef BSD
266*35156Smarc 	"vi",		"/usr/ucb/vi",
267*35156Smarc #else
268*35156Smarc 	"vi",		"/usr/bin/vi",
269*35156Smarc #endif	/* BSD */
270*35156Smarc 	"who",		"/bin/who",
271*35156Smarc #ifdef JOBS
272*35156Smarc #ifdef BSD
273*35156Smarc 	"suspend",	"kill -STOP $$",
274*35156Smarc #endif	/* BSD */
275*35156Smarc #endif	/* JOBS */
276*35156Smarc 	nullstr,	0
277*35156Smarc };
278*35156Smarc 
279*35156Smarc /* tables */
280*35156Smarc SYSTAB reserved=
281*35156Smarc {
282*35156Smarc 		{"case",	CASYM},
283*35156Smarc 		{"do",		DOSYM},
284*35156Smarc 		{"done",	ODSYM},
285*35156Smarc 		{"elif",	EFSYM},
286*35156Smarc 		{"else",	ELSYM},
287*35156Smarc 		{"esac",	ESSYM},
288*35156Smarc 		{"fi",		FISYM},
289*35156Smarc 		{"for",		FORSYM},
290*35156Smarc 		{"function",	PROCSYM},
291*35156Smarc 		{"if",		IFSYM},
292*35156Smarc 		{"in",		INSYM},
293*35156Smarc 		{"select",	SELSYM},
294*35156Smarc 		{"then",	THSYM},
295*35156Smarc 		{"time",	TIMSYM},
296*35156Smarc 		{"until",	UNSYM},
297*35156Smarc 		{"while",	WHSYM},
298*35156Smarc 		{"{",		BRSYM},
299*35156Smarc 		{"}",		KTSYM},
300*35156Smarc 		{nullstr,	0},
301*35156Smarc };
302*35156Smarc 
303*35156Smarc /*
304*35156Smarc  * The signal numbers go in the low bits and the attributes go in the high bits
305*35156Smarc  */
306*35156Smarc 
307*35156Smarc SYSTAB	signal_names =
308*35156Smarc {
309*35156Smarc 		{"ALRM",	(SIGALRM+1)|(SIGCAUGHT<<SIGBITS)},
310*35156Smarc 		{"BUS",		(SIGBUS+1)},
311*35156Smarc #ifdef SIGCHLD
312*35156Smarc 		{"CHLD",	(SIGCHLD+1)|(SIGNOSET<<SIGBITS)},
313*35156Smarc #endif	/* SIGCHLD */
314*35156Smarc #ifdef SIGCLD
315*35156Smarc 		{"CLD",		(SIGCLD+1)|(SIGNOSET<<SIGBITS)},
316*35156Smarc #endif	/* SIGCLD */
317*35156Smarc #ifdef SIGCONT
318*35156Smarc 		{"CONT",	(SIGCONT+1)|(SIGNOSET<<SIGBITS)},
319*35156Smarc #endif	/* SIGCONT */
320*35156Smarc 		{"EMT",		(SIGEMT+1)},
321*35156Smarc 		{"ERR",		(MAXTRAP+1)|(SIGIGNORE<<SIGBITS)},
322*35156Smarc 		{"EXIT",	1|(SIGIGNORE<<SIGBITS)},
323*35156Smarc 		{"FPE",		(SIGFPE+1)},
324*35156Smarc 		{"HUP",		(SIGHUP+1)},
325*35156Smarc 		{"ILL",		(SIGILL+1)|(SIGNOSET<<SIGBITS)},
326*35156Smarc 		{"INT",		(SIGINT+1)|(SIGCAUGHT<<SIGBITS)},
327*35156Smarc #ifdef SIGIO
328*35156Smarc 		{"IO",		(SIGIO+1)|(SIGNOSET<<SIGBITS)},
329*35156Smarc #endif	/* SIGIO */
330*35156Smarc 		{"IOT",		(SIGIOT+1)},
331*35156Smarc 		{"KILL",	(SIGKILL+1)|(SIGIGNORE<<SIGBITS)},
332*35156Smarc #ifdef SIGPHONE
333*35156Smarc 		{"PHONE",	(SIGPHONE+1)|((SIGNOSET|SIGCAUGHT)<<SIGBITS)},
334*35156Smarc #endif	/* SIGPHONE */
335*35156Smarc 		{"PIPE",	(SIGPIPE+1)},
336*35156Smarc #ifdef SIGPOLL
337*35156Smarc 		{"POLL",	(SIGPOLL+1)|((SIGNOSET|SIGCAUGHT)<<SIGBITS)},
338*35156Smarc #endif	/* SIGPOLL */
339*35156Smarc #ifdef SIGPROF
340*35156Smarc 		{"PROF",	(SIGPROF+1)|(SIGNOSET<<SIGBITS)},
341*35156Smarc #endif	/* SIGPROF */
342*35156Smarc #ifdef SIGPWR
343*35156Smarc # if SIGPWR>0
344*35156Smarc 		{"PWR",		(SIGPWR+1)|(SIGNOSET<<SIGBITS)},
345*35156Smarc # endif
346*35156Smarc #endif	/* SIGPWR */
347*35156Smarc 		{"QUIT",	(SIGQUIT+1)|((SIGNOSET|SIGCAUGHT)<<SIGBITS)},
348*35156Smarc 		{"SEGV",	(SIGSEGV+1)},
349*35156Smarc #ifdef SIGSTOP
350*35156Smarc 		{"STOP",	(SIGSTOP+1)|(SIGNOSET<<SIGBITS)},
351*35156Smarc #endif	/* SIGSTOP */
352*35156Smarc 		{"SYS",		(SIGSYS+1)|(SIGNOSET<<SIGBITS)},
353*35156Smarc 		{"TERM",	(SIGTERM+1)|(SIGCAUGHT<<SIGBITS)},
354*35156Smarc #ifdef SIGTINT
355*35156Smarc 		{"TINT",	(SIGTINT+1)|(SIGNOSET<<SIGBITS)},
356*35156Smarc #endif	/* SIGTINT */
357*35156Smarc 		{"TRAP",	(SIGTRAP+1)|(SIGNOSET<<SIGBITS)},
358*35156Smarc #ifdef SIGTSTP
359*35156Smarc 		{"TSTP",	(SIGTSTP+1)|(SIGNOSET<<SIGBITS)},
360*35156Smarc #endif	/* SIGTSTP */
361*35156Smarc #ifdef SIGTTIN
362*35156Smarc 		{"TTIN",	(SIGTTIN+1)|(SIGNOSET<<SIGBITS)},
363*35156Smarc #endif	/* SIGTTIN */
364*35156Smarc #ifdef SIGTTOU
365*35156Smarc 		{"TTOU",	(SIGTTOU+1)|(SIGNOSET<<SIGBITS)},
366*35156Smarc #endif	/* SIGTTOU */
367*35156Smarc #ifdef SIGURG
368*35156Smarc 		{"URG",		(SIGURG+1)|(SIGNOSET<<SIGBITS)},
369*35156Smarc #endif	/* SIGURG */
370*35156Smarc #ifdef SIGUSR1
371*35156Smarc 		{"USR1",	(SIGUSR1+1)},
372*35156Smarc #endif	/* SIGUSR1 */
373*35156Smarc #ifdef SIGUSR2
374*35156Smarc 		{"USR2",	(SIGUSR2+1)},
375*35156Smarc #endif	/* SIGUSR2 */
376*35156Smarc #ifdef SIGVTALRM
377*35156Smarc 		{"VTALRM",	(SIGVTALRM+1)|(SIGNOSET<<SIGBITS)},
378*35156Smarc #endif	/* SIGVTALRM */
379*35156Smarc #ifdef SIGWINCH
380*35156Smarc 		{"WINCH",	(SIGWINCH+1)|((SIGNOSET|SIGCAUGHT)<<SIGBITS)},
381*35156Smarc #endif	/* SIGWINCH */
382*35156Smarc #ifdef SIGWIND
383*35156Smarc 		{"WIND",	(SIGWIND+1)|((SIGNOSET|SIGCAUGHT)<<SIGBITS)},
384*35156Smarc #endif	/* SIGWIND */
385*35156Smarc #ifdef SIGXCPU
386*35156Smarc 		{"XCPU",	(SIGXCPU+1)|(SIGNOSET<<SIGBITS)},
387*35156Smarc #endif	/* SIGXCPU */
388*35156Smarc #ifdef SIGXFSZ
389*35156Smarc 		{"XFSZ",	(SIGXFSZ+1)|(SIGNOSET<<SIGBITS)},
390*35156Smarc #endif	/* SIGXFSZ */
391*35156Smarc 		{nullstr,	0}
392*35156Smarc };
393*35156Smarc 
394*35156Smarc SYSTAB	sig_messages =
395*35156Smarc {
396*35156Smarc 		{"Alarm call",			(SIGALRM+1)},
397*35156Smarc 		{"Bus error",			(SIGBUS+1)},
398*35156Smarc #ifdef SIGCHLD
399*35156Smarc 		{"Child stopped or terminated",	(SIGCHLD+1)},
400*35156Smarc #endif	/* SIGCHLD */
401*35156Smarc #ifdef SIGCLD
402*35156Smarc 		{"Death of Child", 		(SIGCLD+1)},
403*35156Smarc #endif	/* SIGCLD */
404*35156Smarc #ifdef SIGCONT
405*35156Smarc 		{"Stopped process continued",	(SIGCONT+1)},
406*35156Smarc #endif	/* SIGCONT */
407*35156Smarc 		{"EMT trap",			(SIGEMT+1)},
408*35156Smarc 		{"Floating exception",		(SIGFPE+1)},
409*35156Smarc 		{"Hangup",			(SIGHUP+1)},
410*35156Smarc 		{"Illegal instruction",		(SIGILL+1)},
411*35156Smarc #ifdef JOBS
412*35156Smarc 		{"Interrupt",			(SIGINT+1)},
413*35156Smarc #else
414*35156Smarc 		{nullstr,			(SIGINT+1)},
415*35156Smarc #endif	/* JOBS */
416*35156Smarc #ifdef SIGIO
417*35156Smarc 		{"IO signal",			(SIGIO+1)},
418*35156Smarc #endif	/* SIGIO */
419*35156Smarc 		{"abort",			(SIGIOT+1)},
420*35156Smarc 		{"Killed",			(SIGKILL+1)},
421*35156Smarc 		{"Quit",			(SIGQUIT+1)},
422*35156Smarc #ifdef JOBS
423*35156Smarc 		{"Broken Pipe",			(SIGPIPE+1)},
424*35156Smarc #else
425*35156Smarc 		{nullstr,			(SIGPIPE+1)},
426*35156Smarc #endif	/* JOBS */
427*35156Smarc #ifdef SIGPROF
428*35156Smarc 		{"Profiling time alarm",	(SIGPROF+1)},
429*35156Smarc #endif	/* SIGPROF */
430*35156Smarc #ifdef SIGPWR
431*35156Smarc # if SIGPWR>0
432*35156Smarc 		{"Power fail",			(SIGPWR+1)},
433*35156Smarc # endif
434*35156Smarc #endif	/* SIGPWR */
435*35156Smarc 		{"Memory fault",		(SIGSEGV+1)},
436*35156Smarc #ifdef SIGSTOP
437*35156Smarc 		{"Stopped (signal)",		(SIGSTOP+1)},
438*35156Smarc #endif	/* SIGSTOP */
439*35156Smarc 		{"Bad system call", 		(SIGSYS+1)},
440*35156Smarc 		{"Terminated",			(SIGTERM+1)},
441*35156Smarc #ifdef SIGTINT
442*35156Smarc #ifdef JOBS
443*35156Smarc 		{"Interrupt",			(SIGTINT+1)},
444*35156Smarc #else
445*35156Smarc 		{nullstr,			(SIGTINT+1)},
446*35156Smarc #endif	/* JOBS */
447*35156Smarc #endif	/* SIGTINT */
448*35156Smarc 		{"Trace/BPT trap",		(SIGTRAP+1)},
449*35156Smarc #ifdef SIGTSTP
450*35156Smarc 		{"Stopped",			(SIGTSTP+1)},
451*35156Smarc #endif	/* SIGTSTP */
452*35156Smarc #ifdef SIGTTIN
453*35156Smarc 		{"Stopped (tty input)",		(SIGTTIN+1)},
454*35156Smarc #endif	/* SIGTTIN */
455*35156Smarc #ifdef SIGTTOU
456*35156Smarc 		{"Stopped(tty output)",		(SIGTTOU+1)},
457*35156Smarc #endif	/* SIGTTOU */
458*35156Smarc #ifdef SIGURG
459*35156Smarc 		{"Socket interrupt",		(SIGURG+1)},
460*35156Smarc #endif	/* SIGURG */
461*35156Smarc #ifdef SIGUSR1
462*35156Smarc 		{"User signal 1",		(SIGUSR1+1)},
463*35156Smarc #endif	/* SIGUSR1 */
464*35156Smarc #ifdef SIGUSR2
465*35156Smarc 		{"User signal 2",		(SIGUSR2+1)},
466*35156Smarc #endif	/* SIGUSR2 */
467*35156Smarc #ifdef SIGVTALRM
468*35156Smarc 		{"Virtual time alarm",		(SIGVTALRM+1)},
469*35156Smarc #endif	/* SIGVTALRM */
470*35156Smarc #ifdef SIGWINCH
471*35156Smarc 		{"Window size change", 		(SIGWINCH+1)},
472*35156Smarc #endif	/* SIGWINCH */
473*35156Smarc #ifdef SIGXCPU
474*35156Smarc 		{"Exceeded CPU time limit",	(SIGXCPU+1)},
475*35156Smarc #endif	/* SIGXCPU */
476*35156Smarc #ifdef SIGXFSZ
477*35156Smarc 		{"Exceeded file size limit",	(SIGXFSZ+1)},
478*35156Smarc #endif	/* SIGXFSZ */
479*35156Smarc 		{nullstr,	0}
480*35156Smarc };
481*35156Smarc 
482*35156Smarc SYSTAB option_flags=
483*35156Smarc {
484*35156Smarc 	{"allexport",		Allexp},
485*35156Smarc 	{"bgnice",		Bgnice},
486*35156Smarc 	{"emacs",		Emacs},
487*35156Smarc 	{"errexit",		Errflg},
488*35156Smarc 	{"gmacs",		Gmacs},
489*35156Smarc 	{"ignoreeof",		Noeof},
490*35156Smarc #ifdef apollo
491*35156Smarc 	{"inprocess",		Inproc},
492*35156Smarc #endif	/* apollo */
493*35156Smarc 	{"interactive",		Intflg},
494*35156Smarc 	{"keyword",		Keyflg},
495*35156Smarc 	{"markdirs",		Markdir},
496*35156Smarc 	{"monitor",		Monitor},
497*35156Smarc 	{"noexec",		Noexec},
498*35156Smarc 	{"noglob",		Noglob},
499*35156Smarc 	{"nounset",		Noset},
500*35156Smarc 	{"protected",		Privmod},
501*35156Smarc 	{"restricted",		Rshflg},
502*35156Smarc 	{"trackall",		Hashall},
503*35156Smarc 	{"verbose",		Readpr},
504*35156Smarc 	{"vi",			Editvi},
505*35156Smarc 	{"viraw",		Viraw},
506*35156Smarc 	{"xtrace",		Execpr},
507*35156Smarc 	{nullstr,		0}
508*35156Smarc };
509*35156Smarc 
510*35156Smarc #ifdef BSD
511*35156Smarc # ifndef apollo
512*35156Smarc char  *limit_names[] =
513*35156Smarc {
514*35156Smarc 	"time(seconds)   ",
515*35156Smarc 	"memory(kbytes)  ",
516*35156Smarc 	"data(kbytes)    ",
517*35156Smarc 	"stack(kbytes)   ",
518*35156Smarc 	"file(blocks)    ",
519*35156Smarc 	"coredump(blocks)"
520*35156Smarc };
521*35156Smarc # endif /* apollo */
522*35156Smarc #endif	/* BSD */
523*35156Smarc 
524*35156Smarc SYSTAB	commands=
525*35156Smarc {
526*35156Smarc 		{".",		SYSDOT},
527*35156Smarc 		{":",		SYSNULL},
528*35156Smarc 		{"[",		SYSTEST},
529*35156Smarc 		{ "alias",	SYSALIAS},
530*35156Smarc #ifdef JOBS
531*35156Smarc #if BSD || SXT
532*35156Smarc 		{ "bg",		SYSBG},
533*35156Smarc #endif	/* BSD */
534*35156Smarc #endif	/* JOBS */
535*35156Smarc 		{"break",	SYSBREAK},
536*35156Smarc 		{"cd",		SYSCD},
537*35156Smarc 		{"continue",	SYSCONT},
538*35156Smarc 		{"echo",	SYSECHO},
539*35156Smarc 		{"exec",	SYSEXEC},
540*35156Smarc 		{"exit",	SYSEXIT},
541*35156Smarc 		{"export",	SYSXPORT},
542*35156Smarc 		{"eval",	SYSEVAL},
543*35156Smarc 		{"fc",		SYSFC},
544*35156Smarc #ifdef JOBS
545*35156Smarc # if BSD || SXT
546*35156Smarc 		{"fg",		SYSFG},
547*35156Smarc # endif /* BSD */
548*35156Smarc #endif	/* JOBS */
549*35156Smarc #ifdef apollo
550*35156Smarc 		{"inlib",	SYSINLIB},
551*35156Smarc 		{"inprocess",	SYSINPROCESS},
552*35156Smarc #endif	/* apollo */
553*35156Smarc #ifdef JOBS
554*35156Smarc 		{"jobs",	SYSJOBS},
555*35156Smarc 		{"kill",	SYSKILL},
556*35156Smarc #endif	/* JOBS */
557*35156Smarc 		{"let",		SYSLET},
558*35156Smarc 		{"login",	SYSLOGIN},
559*35156Smarc #ifndef BSD
560*35156Smarc 		{"newgrp",	SYSLOGIN},
561*35156Smarc #endif	/* BSD */
562*35156Smarc 		{"print",	SYSPRINT},
563*35156Smarc 		{"pwd",		SYSPWD},
564*35156Smarc 		{"read",	SYSREAD},
565*35156Smarc 		{"readonly",	SYSRDONLY},
566*35156Smarc 		{"return",	SYSRETURN},
567*35156Smarc 		{"set",		SYSSET},
568*35156Smarc 		{"shift",	SYSSHFT},
569*35156Smarc 		{"test",	SYSTEST},
570*35156Smarc 		{"times",	SYSTIMES},
571*35156Smarc 		{"trap",	SYSTRAP},
572*35156Smarc 		{"typeset",	SYSTYPESET},
573*35156Smarc 		{"ulimit",	SYSULIMIT},
574*35156Smarc 		{"umask",	SYSUMASK},
575*35156Smarc 		{"unalias",	SYSUNALIAS},
576*35156Smarc 		{"unset",	SYSUNSET},
577*35156Smarc 		{"wait",	SYSWAIT},
578*35156Smarc 		{"whence",	SYSWHENCE},
579*35156Smarc 		{nullstr,		0}
580*35156Smarc };
581*35156Smarc 
582*35156Smarc SYSTAB	testops =
583*35156Smarc {
584*35156Smarc 		{"!=",		TEST_SNE},
585*35156Smarc 		{"-a",		TEST_AND},
586*35156Smarc 		{"-ef",		TEST_EF},
587*35156Smarc 		{"-eq",		TEST_EQ},
588*35156Smarc 		{"-ge",		TEST_GE},
589*35156Smarc 		{"-gt",		TEST_GT},
590*35156Smarc 		{"-le",		TEST_LE},
591*35156Smarc 		{"-lt",		TEST_LT},
592*35156Smarc 		{"-ne",		TEST_NE},
593*35156Smarc 		{"-nt",		TEST_NT},
594*35156Smarc 		{"-o",		TEST_OR},
595*35156Smarc 		{"-ot",		TEST_OT},
596*35156Smarc 		{"=",		TEST_SEQ},
597*35156Smarc 		{nullstr,	0}
598*35156Smarc };
599*35156Smarc 
600*35156Smarc SYSTAB	attributes =
601*35156Smarc {
602*35156Smarc 		{"export",	N_EXPORT},
603*35156Smarc 		{"readonly",	N_RDONLY},
604*35156Smarc 		{"tagged",	T_FORM},
605*35156Smarc #ifdef apollo
606*35156Smarc 		{" filename",	A_FLAG},
607*35156Smarc #endif	/* apollo */
608*35156Smarc 		{"long",	(L_FLAG|INT_GER)},
609*35156Smarc 		{"unsigned",	(UN_SIGN|INT_GER)},
610*35156Smarc 		{"function",	(BLT_NOD|INT_GER)},
611*35156Smarc 		{"integer",	INT_GER},
612*35156Smarc 		{"lowercase",	U_TO_L},
613*35156Smarc 		{"zerofill",	Z_FILL},
614*35156Smarc 		{"leftjust",	L_JUST},
615*35156Smarc 		{"rightjust",	R_JUST},
616*35156Smarc 		{"uppercase",	L_TO_U},
617*35156Smarc 		{nullstr,	0}
618*35156Smarc };
619*35156Smarc 
620*35156Smarc 
621*35156Smarc #ifdef BSD
622*35156Smarc int tty_speeds[] = {0, 50, 75, 110, 134, 150, 200, 300,
623*35156Smarc 			600,1200,1800,2400,9600,19200,0};
624*35156Smarc #endif /* BSD */
625*35156Smarc 
626*35156Smarc #ifdef MULTIBYTE
627*35156Smarc char int_charsize[] =
628*35156Smarc {
629*35156Smarc 	1, CCS1_IN_SIZE, CCS2_IN_SIZE, CCS3_IN_SIZE,	/* input sizes */
630*35156Smarc 	1, CCS1_OUT_SIZE, CCS2_OUT_SIZE, CCS3_OUT_SIZE	/* output widths */
631*35156Smarc };
632*35156Smarc #endif /* MULTIBYTE */
633*35156Smarc 
634