xref: /titanic_50/usr/src/cmd/sh/msg.c (revision 0a1278f26ea4b7c8c0285d4f2d6c5b680904aa01)
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 (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
28 /*	  All Rights Reserved  	*/
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[]	= "exceeds allowable limit";
78 const char	badreturn[] 	= "cannot return when not in function";
79 const char	badexport[] 	= "cannot export functions";
80 const char	badunset[] 	= "cannot unset";
81 const char	nohome[]	= "no home directory";
82 const char 	badperm[]	= "execute permission denied";
83 const char	longpwd[]	= "sh error: pwd too long";
84 const char	mssgargn[]	= "missing arguments";
85 const char	libacc[] 	= "can't access a needed shared library";
86 const char	libbad[]	= "accessing a corrupted shared library";
87 const char	libscn[]	= ".lib section in a.out corrupted";
88 const char	libmax[]	= "attempting to link in too many libs";
89 const char	emultihop[]	= "Multihop attempted";
90 const char	nulldir[]	= "null directory";
91 const char	enotdir[]	= "not a directory";
92 const char	enoent[]	= "does not exist";
93 const char	eacces[]	= "permission denied";
94 const char	enolink[]	= "remote link inactive";
95 const char	exited[]	= "Done";
96 const char	running[]	= "Running";
97 const char	ambiguous[]	= "ambiguous";
98 const char	usage[]		= "usage";
99 const char	nojc[]		= "no job control";
100 const char	stopuse[]	= "stop id ...";
101 const char	ulimuse[]	= "ulimit [ -HSacdfnstv ] [ limit ]";
102 const char	killuse[]	= "kill [ [ -sig ] id ... | -l ]";
103 const char	jobsuse[]	= "jobs [ [ -l | -p ] [ id ... ] | -x cmd ]";
104 const char	nosuchjob[]	= "no such job";
105 const char	nosuchpid[]	= "no such process";
106 const char	nosuchpgid[]	= "no such process group";
107 const char	nocurjob[]	= "no current job";
108 const char	jobsstopped[]	= "there are stopped jobs";
109 const char	jobsrunning[]	= "there are running jobs";
110 const char	loginsh[]	= "cannot stop login shell";
111 const char	nlorsemi[]	= "newline or ;";
112 const char	signalnum[]	= "Signal ";
113 const char	badpwd[]	= "cannot determine current directory";
114 const char	badlocale[]	= "couldn't set locale correctly\n";
115 const char	nobracket[]	= "] missing";
116 const char	noparen[]	= ") expected";
117 const char	noarg[]		= "argument expected";
118 
119 /*
120  * messages for 'builtin' functions
121  */
122 const char	btest[]		= "test";
123 const char	badop[]		= "unknown operator ";
124 /*
125  * built in names
126  */
127 const char	pathname[]	= "PATH";
128 const char	cdpname[]	= "CDPATH";
129 const char	homename[]	= "HOME";
130 const char	mailname[]	= "MAIL";
131 const char	ifsname[]	= "IFS";
132 const char	ps1name[]	= "PS1";
133 const char	ps2name[]	= "PS2";
134 const char	mchkname[]	= "MAILCHECK";
135 const char	acctname[]  	= "SHACCT";
136 const char	mailpname[]	= "MAILPATH";
137 
138 /*
139  * string constants
140  */
141 const char	nullstr[]	= "";
142 const char	sptbnl[]	= " \t\n";
143 const char	defpath[]	= "/usr/bin:";
144 const char	colon[]		= ": ";
145 const char	minus[]		= "-";
146 const char	endoffile[]	= "end of file";
147 const char	unexpected[] 	= " unexpected";
148 const char	atline[]	= " at line ";
149 const char	devnull[]	= "/dev/null";
150 const char	execpmsg[]	= "+ ";
151 const char	readmsg[]	= "> ";
152 const char	stdprompt[]	= "$ ";
153 const char	supprompt[]	= "# ";
154 const char	profile[]	= ".profile";
155 const char	sysprofile[]	= "/etc/profile";
156 
157 /*
158  * locale testing
159  */
160 const char	localedir[]	= "/usr/lib/locale";
161 int		localedir_exists;
162 
163 /*
164  * tables
165  */
166 
167 const struct sysnod reserved[] =
168 {
169 	{ "case",	CASYM	},
170 	{ "do",		DOSYM	},
171 	{ "done",	ODSYM	},
172 	{ "elif",	EFSYM	},
173 	{ "else",	ELSYM	},
174 	{ "esac",	ESSYM	},
175 	{ "fi",		FISYM	},
176 	{ "for",	FORSYM	},
177 	{ "if",		IFSYM	},
178 	{ "in",		INSYM	},
179 	{ "then",	THSYM	},
180 	{ "until",	UNSYM	},
181 	{ "while",	WHSYM	},
182 	{ "{",		BRSYM	},
183 	{ "}",		KTSYM	}
184 };
185 
186 const int no_reserved = sizeof(reserved)/sizeof(struct sysnod);
187 
188 const char	export[] = "export";
189 const char	readonly[] = "readonly";
190 
191 
192 const struct sysnod commands[] =
193 {
194 	{ ".",		SYSDOT	},
195 	{ ":",		SYSNULL	},
196 
197 #ifndef RES
198 	{ "[",		SYSTST },
199 #endif
200 	{ "bg",		SYSFGBG },
201 	{ "break",	SYSBREAK },
202 	{ "cd",		SYSCD	},
203 	{ "chdir",	SYSCD	},
204 	{ "continue",	SYSCONT	},
205 	{ "echo",	SYSECHO },
206 	{ "eval",	SYSEVAL	},
207 	{ "exec",	SYSEXEC	},
208 	{ "exit",	SYSEXIT	},
209 	{ "export",	SYSXPORT },
210 	{ "fg",		SYSFGBG },
211 	{ "getopts",	SYSGETOPT },
212 	{ "hash",	SYSHASH	},
213 	{ "jobs",	SYSJOBS },
214 	{ "kill",	SYSKILL },
215 #ifdef RES
216 	{ "login",	SYSLOGIN },
217 	{ "newgrp",	SYSLOGIN },
218 #else
219 	{ "newgrp",	SYSNEWGRP },
220 #endif
221 
222 	{ "pwd",	SYSPWD },
223 	{ "read",	SYSREAD	},
224 	{ "readonly",	SYSRDONLY },
225 	{ "return",	SYSRETURN },
226 	{ "set",	SYSSET	},
227 	{ "shift",	SYSSHFT	},
228 	{ "stop",	SYSSTOP	},
229 	{ "suspend",	SYSSUSP},
230 	{ "test",	SYSTST },
231 	{ "times",	SYSTIMES },
232 	{ "trap",	SYSTRAP	},
233 	{ "type",	SYSTYPE },
234 
235 
236 #ifndef RES
237 	{ "ulimit",	SYSULIMIT },
238 	{ "umask",	SYSUMASK },
239 #endif
240 
241 	{ "unset", 	SYSUNS },
242 	{ "wait",	SYSWAIT	}
243 };
244 
245 const int no_commands = sizeof(commands)/sizeof(struct sysnod);
246 
247