xref: /illumos-gate/usr/src/cmd/sh/msg.c (revision 2a8bcb4e)
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  *	UNIX shell
32  */
33 
34 
35 #include	"defs.h"
36 #include	"sym.h"
37 
38 /*
39  * error messages
40  */
41 #ifndef __STDC__
42 #define const
43 #endif
44 
45 const char	badopt[]	= "bad option(s)";
46 const char	mailmsg[]	= "you have mail\n";
47 const char	nospace[]	= "no space";
48 const char	nostack[]	= "no stack space";
49 const char	synmsg[]	= "syntax error";
50 
51 const char	badnum[]	= "bad number";
52 const char	badsig[]	= "bad signal";
53 const char	badid[]		= "invalid id";
54 const char	badparam[]	= "parameter null or not set";
55 const char	unset[]		= "parameter not set";
56 const char	badsub[]	= "bad substitution";
57 const char	badcreate[]	= "cannot create";
58 const char	nofork[]	= "fork failed - too many processes";
59 const char	noswap[]	= "cannot fork: no swap space";
60 const char	restricted[]	= "restricted";
61 const char	piperr[]	= "cannot make pipe";
62 const char	badopen[]	= "cannot open";
63 const char	coredump[]	= " - core dumped";
64 const char	arglist[]	= "arg list too long";
65 const char	txtbsy[]	= "text busy";
66 const char	toobig[]	= "too big";
67 const char	badexec[]	= "cannot execute";
68 const char	notfound[]	= "not found";
69 const char	badfile[]	= "bad file number";
70 const char	badshift[]	= "cannot shift";
71 const char	baddir[]	= "bad directory";
72 const char	badtrap[]	= "bad trap";
73 const char	wtfailed[]	= "is read only";
74 const char	notid[]		= "is not an identifier";
75 const char 	badulimit[]	= "exceeds allowable limit";
76 const char	badreturn[] 	= "cannot return when not in function";
77 const char	badexport[] 	= "cannot export functions";
78 const char	badunset[] 	= "cannot unset";
79 const char	nohome[]	= "no home directory";
80 const char 	badperm[]	= "execute permission denied";
81 const char	longpwd[]	= "sh error: pwd too long";
82 const char	mssgargn[]	= "missing arguments";
83 const char	libacc[] 	= "can't access a needed shared library";
84 const char	libbad[]	= "accessing a corrupted shared library";
85 const char	libscn[]	= ".lib section in a.out corrupted";
86 const char	libmax[]	= "attempting to link in too many libs";
87 const char	emultihop[]	= "Multihop attempted";
88 const char	nulldir[]	= "null directory";
89 const char	enotdir[]	= "not a directory";
90 const char	enoent[]	= "does not exist";
91 const char	eacces[]	= "permission denied";
92 const char	enolink[]	= "remote link inactive";
93 const char	exited[]	= "Done";
94 const char	running[]	= "Running";
95 const char	ambiguous[]	= "ambiguous";
96 const char	usage[]		= "usage";
97 const char	nojc[]		= "no job control";
98 const char	stopuse[]	= "stop id ...";
99 const char	ulimuse[]	= "ulimit [ -HSacdfnstv ] [ limit ]";
100 const char	killuse[]	= "kill [ [ -sig ] id ... | -l ]";
101 const char	jobsuse[]	= "jobs [ [ -l | -p ] [ id ... ] | -x cmd ]";
102 const char	nosuchjob[]	= "no such job";
103 const char	nosuchpid[]	= "no such process";
104 const char	nosuchpgid[]	= "no such process group";
105 const char	nocurjob[]	= "no current job";
106 const char	jobsstopped[]	= "there are stopped jobs";
107 const char	jobsrunning[]	= "there are running jobs";
108 const char	loginsh[]	= "cannot stop login shell";
109 const char	nlorsemi[]	= "newline or ;";
110 const char	signalnum[]	= "Signal ";
111 const char	badpwd[]	= "cannot determine current directory";
112 const char	badlocale[]	= "couldn't set locale correctly\n";
113 const char	nobracket[]	= "] missing";
114 const char	noparen[]	= ") expected";
115 const char	noarg[]		= "argument expected";
116 
117 /*
118  * messages for 'builtin' functions
119  */
120 const char	btest[]		= "test";
121 const char	badop[]		= "unknown operator ";
122 /*
123  * built in names
124  */
125 const char	pathname[]	= "PATH";
126 const char	cdpname[]	= "CDPATH";
127 const char	homename[]	= "HOME";
128 const char	mailname[]	= "MAIL";
129 const char	ifsname[]	= "IFS";
130 const char	ps1name[]	= "PS1";
131 const char	ps2name[]	= "PS2";
132 const char	mchkname[]	= "MAILCHECK";
133 const char	acctname[]  	= "SHACCT";
134 const char	mailpname[]	= "MAILPATH";
135 
136 /*
137  * string constants
138  */
139 const char	nullstr[]	= "";
140 const char	sptbnl[]	= " \t\n";
141 const char	defpath[]	= "/usr/bin:";
142 const char	colon[]		= ": ";
143 const char	minus[]		= "-";
144 const char	endoffile[]	= "end of file";
145 const char	unexpected[] 	= " unexpected";
146 const char	atline[]	= " at line ";
147 const char	devnull[]	= "/dev/null";
148 const char	execpmsg[]	= "+ ";
149 const char	readmsg[]	= "> ";
150 const char	stdprompt[]	= "$ ";
151 const char	supprompt[]	= "# ";
152 const char	profile[]	= ".profile";
153 const char	sysprofile[]	= "/etc/profile";
154 
155 /*
156  * locale testing
157  */
158 const char	localedir[]	= "/usr/lib/locale";
159 int		localedir_exists;
160 
161 /*
162  * tables
163  */
164 
165 const struct sysnod reserved[] =
166 {
167 	{ "case",	CASYM	},
168 	{ "do",		DOSYM	},
169 	{ "done",	ODSYM	},
170 	{ "elif",	EFSYM	},
171 	{ "else",	ELSYM	},
172 	{ "esac",	ESSYM	},
173 	{ "fi",		FISYM	},
174 	{ "for",	FORSYM	},
175 	{ "if",		IFSYM	},
176 	{ "in",		INSYM	},
177 	{ "then",	THSYM	},
178 	{ "until",	UNSYM	},
179 	{ "while",	WHSYM	},
180 	{ "{",		BRSYM	},
181 	{ "}",		KTSYM	}
182 };
183 
184 const int no_reserved = sizeof(reserved)/sizeof(struct sysnod);
185 
186 const char	export[] = "export";
187 const char	readonly[] = "readonly";
188 
189 
190 const struct sysnod commands[] =
191 {
192 	{ ".",		SYSDOT	},
193 	{ ":",		SYSNULL	},
194 
195 #ifndef RES
196 	{ "[",		SYSTST },
197 #endif
198 	{ "bg",		SYSFGBG },
199 	{ "break",	SYSBREAK },
200 	{ "cd",		SYSCD	},
201 	{ "chdir",	SYSCD	},
202 	{ "continue",	SYSCONT	},
203 	{ "echo",	SYSECHO },
204 	{ "eval",	SYSEVAL	},
205 	{ "exec",	SYSEXEC	},
206 	{ "exit",	SYSEXIT	},
207 	{ "export",	SYSXPORT },
208 	{ "fg",		SYSFGBG },
209 	{ "getopts",	SYSGETOPT },
210 	{ "hash",	SYSHASH	},
211 	{ "jobs",	SYSJOBS },
212 	{ "kill",	SYSKILL },
213 #ifdef RES
214 	{ "login",	SYSLOGIN },
215 	{ "newgrp",	SYSLOGIN },
216 #else
217 	{ "newgrp",	SYSNEWGRP },
218 #endif
219 
220 	{ "pwd",	SYSPWD },
221 	{ "read",	SYSREAD	},
222 	{ "readonly",	SYSRDONLY },
223 	{ "return",	SYSRETURN },
224 	{ "set",	SYSSET	},
225 	{ "shift",	SYSSHFT	},
226 	{ "stop",	SYSSTOP	},
227 	{ "suspend",	SYSSUSP},
228 	{ "test",	SYSTST },
229 	{ "times",	SYSTIMES },
230 	{ "trap",	SYSTRAP	},
231 	{ "type",	SYSTYPE },
232 
233 
234 #ifndef RES
235 	{ "ulimit",	SYSULIMIT },
236 	{ "umask",	SYSUMASK },
237 #endif
238 
239 	{ "unset", 	SYSUNS },
240 	{ "wait",	SYSWAIT	}
241 };
242 
243 const int no_commands = sizeof(commands)/sizeof(struct sysnod);
244 
245