xref: /titanic_51/usr/src/cmd/sh/msg.c (revision 39e7390a771e8a17884d4f1558a2a41422b38104)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*39e7390aSna195498  * Common Development and Distribution License (the "License").
6*39e7390aSna195498  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate 
227c478bd9Sstevel@tonic-gate /*
233d9df56cSakaplan  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate 
27*39e7390aSna195498 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
28*39e7390aSna195498 /*	  All Rights Reserved  	*/
29*39e7390aSna195498 
30*39e7390aSna195498 
317c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
327c478bd9Sstevel@tonic-gate /*
337c478bd9Sstevel@tonic-gate  *	UNIX shell
347c478bd9Sstevel@tonic-gate  */
357c478bd9Sstevel@tonic-gate 
367c478bd9Sstevel@tonic-gate 
377c478bd9Sstevel@tonic-gate #include	"defs.h"
387c478bd9Sstevel@tonic-gate #include	"sym.h"
397c478bd9Sstevel@tonic-gate 
407c478bd9Sstevel@tonic-gate /*
417c478bd9Sstevel@tonic-gate  * error messages
427c478bd9Sstevel@tonic-gate  */
437c478bd9Sstevel@tonic-gate #ifndef __STDC__
447c478bd9Sstevel@tonic-gate #define const
457c478bd9Sstevel@tonic-gate #endif
467c478bd9Sstevel@tonic-gate 
477c478bd9Sstevel@tonic-gate const char	badopt[]	= "bad option(s)";
487c478bd9Sstevel@tonic-gate const char	mailmsg[]	= "you have mail\n";
497c478bd9Sstevel@tonic-gate const char	nospace[]	= "no space";
507c478bd9Sstevel@tonic-gate const char	nostack[]	= "no stack space";
517c478bd9Sstevel@tonic-gate const char	synmsg[]	= "syntax error";
527c478bd9Sstevel@tonic-gate 
537c478bd9Sstevel@tonic-gate const char	badnum[]	= "bad number";
547c478bd9Sstevel@tonic-gate const char	badsig[]	= "bad signal";
557c478bd9Sstevel@tonic-gate const char	badid[]		= "invalid id";
567c478bd9Sstevel@tonic-gate const char	badparam[]	= "parameter null or not set";
577c478bd9Sstevel@tonic-gate const char	unset[]		= "parameter not set";
587c478bd9Sstevel@tonic-gate const char	badsub[]	= "bad substitution";
597c478bd9Sstevel@tonic-gate const char	badcreate[]	= "cannot create";
607c478bd9Sstevel@tonic-gate const char	nofork[]	= "fork failed - too many processes";
617c478bd9Sstevel@tonic-gate const char	noswap[]	= "cannot fork: no swap space";
627c478bd9Sstevel@tonic-gate const char	restricted[]	= "restricted";
637c478bd9Sstevel@tonic-gate const char	piperr[]	= "cannot make pipe";
647c478bd9Sstevel@tonic-gate const char	badopen[]	= "cannot open";
657c478bd9Sstevel@tonic-gate const char	coredump[]	= " - core dumped";
667c478bd9Sstevel@tonic-gate const char	arglist[]	= "arg list too long";
677c478bd9Sstevel@tonic-gate const char	txtbsy[]	= "text busy";
687c478bd9Sstevel@tonic-gate const char	toobig[]	= "too big";
697c478bd9Sstevel@tonic-gate const char	badexec[]	= "cannot execute";
707c478bd9Sstevel@tonic-gate const char	notfound[]	= "not found";
717c478bd9Sstevel@tonic-gate const char	badfile[]	= "bad file number";
727c478bd9Sstevel@tonic-gate const char	badshift[]	= "cannot shift";
737c478bd9Sstevel@tonic-gate const char	baddir[]	= "bad directory";
747c478bd9Sstevel@tonic-gate const char	badtrap[]	= "bad trap";
757c478bd9Sstevel@tonic-gate const char	wtfailed[]	= "is read only";
767c478bd9Sstevel@tonic-gate const char	notid[]		= "is not an identifier";
773d9df56cSakaplan const char 	badulimit[]	= "exceeds allowable limit";
787c478bd9Sstevel@tonic-gate const char	badreturn[] 	= "cannot return when not in function";
797c478bd9Sstevel@tonic-gate const char	badexport[] 	= "cannot export functions";
807c478bd9Sstevel@tonic-gate const char	badunset[] 	= "cannot unset";
817c478bd9Sstevel@tonic-gate const char	nohome[]	= "no home directory";
827c478bd9Sstevel@tonic-gate const char 	badperm[]	= "execute permission denied";
837c478bd9Sstevel@tonic-gate const char	longpwd[]	= "sh error: pwd too long";
847c478bd9Sstevel@tonic-gate const char	mssgargn[]	= "missing arguments";
857c478bd9Sstevel@tonic-gate const char	libacc[] 	= "can't access a needed shared library";
867c478bd9Sstevel@tonic-gate const char	libbad[]	= "accessing a corrupted shared library";
877c478bd9Sstevel@tonic-gate const char	libscn[]	= ".lib section in a.out corrupted";
887c478bd9Sstevel@tonic-gate const char	libmax[]	= "attempting to link in too many libs";
897c478bd9Sstevel@tonic-gate const char	emultihop[]	= "Multihop attempted";
907c478bd9Sstevel@tonic-gate const char	nulldir[]	= "null directory";
917c478bd9Sstevel@tonic-gate const char	enotdir[]	= "not a directory";
927c478bd9Sstevel@tonic-gate const char	enoent[]	= "does not exist";
937c478bd9Sstevel@tonic-gate const char	eacces[]	= "permission denied";
947c478bd9Sstevel@tonic-gate const char	enolink[]	= "remote link inactive";
957c478bd9Sstevel@tonic-gate const char	exited[]	= "Done";
967c478bd9Sstevel@tonic-gate const char	running[]	= "Running";
977c478bd9Sstevel@tonic-gate const char	ambiguous[]	= "ambiguous";
987c478bd9Sstevel@tonic-gate const char	usage[]		= "usage";
997c478bd9Sstevel@tonic-gate const char	nojc[]		= "no job control";
1007c478bd9Sstevel@tonic-gate const char	stopuse[]	= "stop id ...";
1017c478bd9Sstevel@tonic-gate const char	ulimuse[]	= "ulimit [ -HSacdfnstv ] [ limit ]";
1027c478bd9Sstevel@tonic-gate const char	killuse[]	= "kill [ [ -sig ] id ... | -l ]";
1037c478bd9Sstevel@tonic-gate const char	jobsuse[]	= "jobs [ [ -l | -p ] [ id ... ] | -x cmd ]";
1047c478bd9Sstevel@tonic-gate const char	nosuchjob[]	= "no such job";
1057c478bd9Sstevel@tonic-gate const char	nosuchpid[]	= "no such process";
1067c478bd9Sstevel@tonic-gate const char	nosuchpgid[]	= "no such process group";
1077c478bd9Sstevel@tonic-gate const char	nocurjob[]	= "no current job";
1087c478bd9Sstevel@tonic-gate const char	jobsstopped[]	= "there are stopped jobs";
1097c478bd9Sstevel@tonic-gate const char	jobsrunning[]	= "there are running jobs";
1107c478bd9Sstevel@tonic-gate const char	loginsh[]	= "cannot stop login shell";
111*39e7390aSna195498 const char	nlorsemi[]	= "newline or ;";
112*39e7390aSna195498 const char	signalnum[]	= "Signal ";
113*39e7390aSna195498 const char	badpwd[]	= "cannot determine current directory";
114*39e7390aSna195498 const char	badlocale[]	= "couldn't set locale correctly\n";
115*39e7390aSna195498 const char	nobracket[]	= "] missing";
116*39e7390aSna195498 const char	noparen[]	= ") expected";
117*39e7390aSna195498 const char	noarg[]		= "argument expected";
1187c478bd9Sstevel@tonic-gate 
1197c478bd9Sstevel@tonic-gate /*
1207c478bd9Sstevel@tonic-gate  * messages for 'builtin' functions
1217c478bd9Sstevel@tonic-gate  */
1227c478bd9Sstevel@tonic-gate const char	btest[]		= "test";
1237c478bd9Sstevel@tonic-gate const char	badop[]		= "unknown operator ";
1247c478bd9Sstevel@tonic-gate /*
1257c478bd9Sstevel@tonic-gate  * built in names
1267c478bd9Sstevel@tonic-gate  */
1277c478bd9Sstevel@tonic-gate const char	pathname[]	= "PATH";
1287c478bd9Sstevel@tonic-gate const char	cdpname[]	= "CDPATH";
1297c478bd9Sstevel@tonic-gate const char	homename[]	= "HOME";
1307c478bd9Sstevel@tonic-gate const char	mailname[]	= "MAIL";
1317c478bd9Sstevel@tonic-gate const char	ifsname[]	= "IFS";
1327c478bd9Sstevel@tonic-gate const char	ps1name[]	= "PS1";
1337c478bd9Sstevel@tonic-gate const char	ps2name[]	= "PS2";
1347c478bd9Sstevel@tonic-gate const char	mchkname[]	= "MAILCHECK";
1357c478bd9Sstevel@tonic-gate const char	acctname[]  	= "SHACCT";
1367c478bd9Sstevel@tonic-gate const char	mailpname[]	= "MAILPATH";
1377c478bd9Sstevel@tonic-gate 
1387c478bd9Sstevel@tonic-gate /*
1397c478bd9Sstevel@tonic-gate  * string constants
1407c478bd9Sstevel@tonic-gate  */
1417c478bd9Sstevel@tonic-gate const char	nullstr[]	= "";
1427c478bd9Sstevel@tonic-gate const char	sptbnl[]	= " \t\n";
1437c478bd9Sstevel@tonic-gate const char	defpath[]	= "/usr/bin:";
1447c478bd9Sstevel@tonic-gate const char	colon[]		= ": ";
1457c478bd9Sstevel@tonic-gate const char	minus[]		= "-";
1467c478bd9Sstevel@tonic-gate const char	endoffile[]	= "end of file";
1477c478bd9Sstevel@tonic-gate const char	unexpected[] 	= " unexpected";
1487c478bd9Sstevel@tonic-gate const char	atline[]	= " at line ";
1497c478bd9Sstevel@tonic-gate const char	devnull[]	= "/dev/null";
1507c478bd9Sstevel@tonic-gate const char	execpmsg[]	= "+ ";
1517c478bd9Sstevel@tonic-gate const char	readmsg[]	= "> ";
1527c478bd9Sstevel@tonic-gate const char	stdprompt[]	= "$ ";
1537c478bd9Sstevel@tonic-gate const char	supprompt[]	= "# ";
1547c478bd9Sstevel@tonic-gate const char	profile[]	= ".profile";
1557c478bd9Sstevel@tonic-gate const char	sysprofile[]	= "/etc/profile";
1567c478bd9Sstevel@tonic-gate 
1577c478bd9Sstevel@tonic-gate /*
1587c478bd9Sstevel@tonic-gate  * locale testing
1597c478bd9Sstevel@tonic-gate  */
1607c478bd9Sstevel@tonic-gate const char	localedir[]	= "/usr/lib/locale";
1617c478bd9Sstevel@tonic-gate int		localedir_exists;
1627c478bd9Sstevel@tonic-gate 
1637c478bd9Sstevel@tonic-gate /*
1647c478bd9Sstevel@tonic-gate  * tables
1657c478bd9Sstevel@tonic-gate  */
1667c478bd9Sstevel@tonic-gate 
1677c478bd9Sstevel@tonic-gate const struct sysnod reserved[] =
1687c478bd9Sstevel@tonic-gate {
1697c478bd9Sstevel@tonic-gate 	{ "case",	CASYM	},
1707c478bd9Sstevel@tonic-gate 	{ "do",		DOSYM	},
1717c478bd9Sstevel@tonic-gate 	{ "done",	ODSYM	},
1727c478bd9Sstevel@tonic-gate 	{ "elif",	EFSYM	},
1737c478bd9Sstevel@tonic-gate 	{ "else",	ELSYM	},
1747c478bd9Sstevel@tonic-gate 	{ "esac",	ESSYM	},
1757c478bd9Sstevel@tonic-gate 	{ "fi",		FISYM	},
1767c478bd9Sstevel@tonic-gate 	{ "for",	FORSYM	},
1777c478bd9Sstevel@tonic-gate 	{ "if",		IFSYM	},
1787c478bd9Sstevel@tonic-gate 	{ "in",		INSYM	},
1797c478bd9Sstevel@tonic-gate 	{ "then",	THSYM	},
1807c478bd9Sstevel@tonic-gate 	{ "until",	UNSYM	},
1817c478bd9Sstevel@tonic-gate 	{ "while",	WHSYM	},
1827c478bd9Sstevel@tonic-gate 	{ "{",		BRSYM	},
1837c478bd9Sstevel@tonic-gate 	{ "}",		KTSYM	}
1847c478bd9Sstevel@tonic-gate };
1857c478bd9Sstevel@tonic-gate 
1867c478bd9Sstevel@tonic-gate const int no_reserved = sizeof(reserved)/sizeof(struct sysnod);
1877c478bd9Sstevel@tonic-gate 
1887c478bd9Sstevel@tonic-gate const char	export[] = "export";
1897c478bd9Sstevel@tonic-gate const char	readonly[] = "readonly";
1907c478bd9Sstevel@tonic-gate 
1917c478bd9Sstevel@tonic-gate 
1927c478bd9Sstevel@tonic-gate const struct sysnod commands[] =
1937c478bd9Sstevel@tonic-gate {
1947c478bd9Sstevel@tonic-gate 	{ ".",		SYSDOT	},
1957c478bd9Sstevel@tonic-gate 	{ ":",		SYSNULL	},
1967c478bd9Sstevel@tonic-gate 
1977c478bd9Sstevel@tonic-gate #ifndef RES
1987c478bd9Sstevel@tonic-gate 	{ "[",		SYSTST },
1997c478bd9Sstevel@tonic-gate #endif
2007c478bd9Sstevel@tonic-gate 	{ "bg",		SYSFGBG },
2017c478bd9Sstevel@tonic-gate 	{ "break",	SYSBREAK },
2027c478bd9Sstevel@tonic-gate 	{ "cd",		SYSCD	},
2037c478bd9Sstevel@tonic-gate 	{ "chdir",	SYSCD	},
2047c478bd9Sstevel@tonic-gate 	{ "continue",	SYSCONT	},
2057c478bd9Sstevel@tonic-gate 	{ "echo",	SYSECHO },
2067c478bd9Sstevel@tonic-gate 	{ "eval",	SYSEVAL	},
2077c478bd9Sstevel@tonic-gate 	{ "exec",	SYSEXEC	},
2087c478bd9Sstevel@tonic-gate 	{ "exit",	SYSEXIT	},
2097c478bd9Sstevel@tonic-gate 	{ "export",	SYSXPORT },
2107c478bd9Sstevel@tonic-gate 	{ "fg",		SYSFGBG },
2117c478bd9Sstevel@tonic-gate 	{ "getopts",	SYSGETOPT },
2127c478bd9Sstevel@tonic-gate 	{ "hash",	SYSHASH	},
2137c478bd9Sstevel@tonic-gate 	{ "jobs",	SYSJOBS },
2147c478bd9Sstevel@tonic-gate 	{ "kill",	SYSKILL },
2157c478bd9Sstevel@tonic-gate #ifdef RES
2167c478bd9Sstevel@tonic-gate 	{ "login",	SYSLOGIN },
2177c478bd9Sstevel@tonic-gate 	{ "newgrp",	SYSLOGIN },
2187c478bd9Sstevel@tonic-gate #else
2197c478bd9Sstevel@tonic-gate 	{ "newgrp",	SYSNEWGRP },
2207c478bd9Sstevel@tonic-gate #endif
2217c478bd9Sstevel@tonic-gate 
2227c478bd9Sstevel@tonic-gate 	{ "pwd",	SYSPWD },
2237c478bd9Sstevel@tonic-gate 	{ "read",	SYSREAD	},
2247c478bd9Sstevel@tonic-gate 	{ "readonly",	SYSRDONLY },
2257c478bd9Sstevel@tonic-gate 	{ "return",	SYSRETURN },
2267c478bd9Sstevel@tonic-gate 	{ "set",	SYSSET	},
2277c478bd9Sstevel@tonic-gate 	{ "shift",	SYSSHFT	},
2287c478bd9Sstevel@tonic-gate 	{ "stop",	SYSSTOP	},
2297c478bd9Sstevel@tonic-gate 	{ "suspend",	SYSSUSP},
2307c478bd9Sstevel@tonic-gate 	{ "test",	SYSTST },
2317c478bd9Sstevel@tonic-gate 	{ "times",	SYSTIMES },
2327c478bd9Sstevel@tonic-gate 	{ "trap",	SYSTRAP	},
2337c478bd9Sstevel@tonic-gate 	{ "type",	SYSTYPE },
2347c478bd9Sstevel@tonic-gate 
2357c478bd9Sstevel@tonic-gate 
2367c478bd9Sstevel@tonic-gate #ifndef RES
2377c478bd9Sstevel@tonic-gate 	{ "ulimit",	SYSULIMIT },
2387c478bd9Sstevel@tonic-gate 	{ "umask",	SYSUMASK },
2397c478bd9Sstevel@tonic-gate #endif
2407c478bd9Sstevel@tonic-gate 
2417c478bd9Sstevel@tonic-gate 	{ "unset", 	SYSUNS },
2427c478bd9Sstevel@tonic-gate 	{ "wait",	SYSWAIT	}
2437c478bd9Sstevel@tonic-gate };
2447c478bd9Sstevel@tonic-gate 
2457c478bd9Sstevel@tonic-gate const int no_commands = sizeof(commands)/sizeof(struct sysnod);
2467c478bd9Sstevel@tonic-gate 
247