xref: /titanic_41/usr/src/cmd/sh/msg.c (revision fd9cb95cbb2f626355a60efb9d02c5f0a33c10e6)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
23 /*	  All Rights Reserved  	*/
24 
25 
26 /*
27  * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
28  * Use is subject to license terms.
29  */
30 
31 #pragma ident	"%Z%%M%	%I%	%E% SMI"
32 /*
33  *	UNIX shell
34  */
35 
36 
37 #include	"defs.h"
38 #include	"sym.h"
39 
40 /*
41  * error messages
42  */
43 #ifndef __STDC__
44 #define const
45 #endif
46 
47 const char	badopt[]	= "bad option(s)";
48 const char	mailmsg[]	= "you have mail\n";
49 const char	nospace[]	= "no space";
50 const char	nostack[]	= "no stack space";
51 const char	synmsg[]	= "syntax error";
52 
53 const char	badnum[]	= "bad number";
54 const char	badsig[]	= "bad signal";
55 const char	badid[]		= "invalid id";
56 const char	badparam[]	= "parameter null or not set";
57 const char	unset[]		= "parameter not set";
58 const char	badsub[]	= "bad substitution";
59 const char	badcreate[]	= "cannot create";
60 const char	nofork[]	= "fork failed - too many processes";
61 const char	noswap[]	= "cannot fork: no swap space";
62 const char	restricted[]	= "restricted";
63 const char	piperr[]	= "cannot make pipe";
64 const char	badopen[]	= "cannot open";
65 const char	coredump[]	= " - core dumped";
66 const char	arglist[]	= "arg list too long";
67 const char	txtbsy[]	= "text busy";
68 const char	toobig[]	= "too big";
69 const char	badexec[]	= "cannot execute";
70 const char	notfound[]	= "not found";
71 const char	badfile[]	= "bad file number";
72 const char	badshift[]	= "cannot shift";
73 const char	baddir[]	= "bad directory";
74 const char	badtrap[]	= "bad trap";
75 const char	wtfailed[]	= "is read only";
76 const char	notid[]		= "is not an identifier";
77 const char 	badulimit[]	= "bad ulimit";
78 const char 	badresource[]	= "no such resource";
79 const char	badreturn[] 	= "cannot return when not in function";
80 const char	badexport[] 	= "cannot export functions";
81 const char	badunset[] 	= "cannot unset";
82 const char	nohome[]	= "no home directory";
83 const char 	badperm[]	= "execute permission denied";
84 const char	longpwd[]	= "sh error: pwd too long";
85 const char	mssgargn[]	= "missing arguments";
86 const char	libacc[] 	= "can't access a needed shared library";
87 const char	libbad[]	= "accessing a corrupted shared library";
88 const char	libscn[]	= ".lib section in a.out corrupted";
89 const char	libmax[]	= "attempting to link in too many libs";
90 const char    emultihop[]     = "Multihop attempted";
91 const char    nulldir[]       = "null directory";
92 const char    enotdir[]       = "not a directory";
93 const char    enoent[]        = "does not exist";
94 const char    eacces[]        = "permission denied";
95 const char    enolink[]       = "remote link inactive";
96 const char badscale[] 		= "bad scaling";
97 const char exited[]		= "Done";
98 const char running[]		= "Running";
99 const char ambiguous[]		= "ambiguous";
100 const char usage[]		= "usage";
101 const char nojc[]		= "no job control";
102 const char stopuse[]		= "stop id ...";
103 const char ulimuse[]		= "ulimit [ -HSacdfnstv ] [ limit ]";
104 const char killuse[]		= "kill [ [ -sig ] id ... | -l ]";
105 const char jobsuse[]		= "jobs [ [ -l | -p ] [ id ... ] | -x cmd ]";
106 const char nosuchjob[]		= "no such job";
107 const char nosuchpid[]		= "no such process";
108 const char nosuchpgid[]		= "no such process group";
109 const char nocurjob[]		= "no current job";
110 const char jobsstopped[]	= "there are stopped jobs";
111 const char jobsrunning[]	= "there are running jobs";
112 const char loginsh[]		= "cannot stop login shell";
113 
114 /*
115  * messages for 'builtin' functions
116  */
117 const char	btest[]		= "test";
118 const char	badop[]		= "unknown operator ";
119 /*
120  * built in names
121  */
122 const char	pathname[]	= "PATH";
123 const char	cdpname[]	= "CDPATH";
124 const char	homename[]	= "HOME";
125 const char	mailname[]	= "MAIL";
126 const char	ifsname[]	= "IFS";
127 const char	ps1name[]	= "PS1";
128 const char	ps2name[]	= "PS2";
129 const char	mchkname[]	= "MAILCHECK";
130 const char	acctname[]  	= "SHACCT";
131 const char	mailpname[]	= "MAILPATH";
132 
133 /*
134  * string constants
135  */
136 const char	nullstr[]	= "";
137 const char	sptbnl[]	= " \t\n";
138 const char	defpath[]	= "/usr/bin:";
139 const char	colon[]		= ": ";
140 const char	minus[]		= "-";
141 const char	endoffile[]	= "end of file";
142 const char	unexpected[] 	= " unexpected";
143 const char	atline[]	= " at line ";
144 const char	devnull[]	= "/dev/null";
145 const char	execpmsg[]	= "+ ";
146 const char	readmsg[]	= "> ";
147 const char	stdprompt[]	= "$ ";
148 const char	supprompt[]	= "# ";
149 const char	profile[]	= ".profile";
150 const char	sysprofile[]	= "/etc/profile";
151 
152 /*
153  * locale testing
154  */
155 const char	localedir[]	= "/usr/lib/locale";
156 int		localedir_exists;
157 
158 /*
159  * tables
160  */
161 
162 const struct sysnod reserved[] =
163 {
164 	{ "case",	CASYM	},
165 	{ "do",		DOSYM	},
166 	{ "done",	ODSYM	},
167 	{ "elif",	EFSYM	},
168 	{ "else",	ELSYM	},
169 	{ "esac",	ESSYM	},
170 	{ "fi",		FISYM	},
171 	{ "for",	FORSYM	},
172 	{ "if",		IFSYM	},
173 	{ "in",		INSYM	},
174 	{ "then",	THSYM	},
175 	{ "until",	UNSYM	},
176 	{ "while",	WHSYM	},
177 	{ "{",		BRSYM	},
178 	{ "}",		KTSYM	}
179 };
180 
181 const int no_reserved = sizeof(reserved)/sizeof(struct sysnod);
182 
183 const char	*sysmsg[] =
184 {
185 	0,
186 	"Hangup",
187 	0,	/* Interrupt */
188 	"Quit",
189 	"Illegal instruction",
190 	"Trace/BPT trap",
191 	"abort",
192 	"EMT trap",
193 	"Floating exception",
194 	"Killed",
195 	"Bus error",
196 	"Memory fault",
197 	"Bad system call",
198 	0,	/* Broken pipe */
199 	"Alarm call",
200 	"Terminated",
201 	"Signal 16",
202 	"Signal 17",
203 	"Child death",
204 	"Power Fail"
205 };
206 
207 const char	export[] = "export";
208 const char	duperr[] = "cannot dup";
209 const char	readonly[] = "readonly";
210 
211 
212 const struct sysnod commands[] =
213 {
214 	{ ".",		SYSDOT	},
215 	{ ":",		SYSNULL	},
216 
217 #ifndef RES
218 	{ "[",		SYSTST },
219 #endif
220 	{ "bg",		SYSFGBG },
221 	{ "break",	SYSBREAK },
222 	{ "cd",		SYSCD	},
223 	{ "chdir",	SYSCD	},
224 	{ "continue",	SYSCONT	},
225 	{ "echo",	SYSECHO },
226 	{ "eval",	SYSEVAL	},
227 	{ "exec",	SYSEXEC	},
228 	{ "exit",	SYSEXIT	},
229 	{ "export",	SYSXPORT },
230 	{ "fg",		SYSFGBG },
231 	{ "getopts",	SYSGETOPT },
232 	{ "hash",	SYSHASH	},
233 	{ "jobs",	SYSJOBS },
234 	{ "kill",	SYSKILL },
235 #ifdef RES
236 	{ "login",	SYSLOGIN },
237 	{ "newgrp",	SYSLOGIN },
238 #else
239 	{ "newgrp",	SYSNEWGRP },
240 #endif
241 
242 	{ "pwd",	SYSPWD },
243 	{ "read",	SYSREAD	},
244 	{ "readonly",	SYSRDONLY },
245 	{ "return",	SYSRETURN },
246 	{ "set",	SYSSET	},
247 	{ "shift",	SYSSHFT	},
248 	{ "stop",	SYSSTOP	},
249 	{ "suspend",	SYSSUSP},
250 	{ "test",	SYSTST },
251 	{ "times",	SYSTIMES },
252 	{ "trap",	SYSTRAP	},
253 	{ "type",	SYSTYPE },
254 
255 
256 #ifndef RES
257 	{ "ulimit",	SYSULIMIT },
258 	{ "umask",	SYSUMASK },
259 #endif
260 
261 	{ "unset", 	SYSUNS },
262 	{ "wait",	SYSWAIT	}
263 };
264 
265 const int no_commands = sizeof(commands)/sizeof(struct sysnod);
266 
267