xref: /onnv-gate/usr/src/cmd/sh/msg.c (revision 2256:a9ca1c675600)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*2256Sna195498  * Common Development and Distribution License (the "License").
6*2256Sna195498  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate 
220Sstevel@tonic-gate /*
231367Sakaplan  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
240Sstevel@tonic-gate  * Use is subject to license terms.
250Sstevel@tonic-gate  */
260Sstevel@tonic-gate 
27*2256Sna195498 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
28*2256Sna195498 /*	  All Rights Reserved  	*/
29*2256Sna195498 
30*2256Sna195498 
310Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
320Sstevel@tonic-gate /*
330Sstevel@tonic-gate  *	UNIX shell
340Sstevel@tonic-gate  */
350Sstevel@tonic-gate 
360Sstevel@tonic-gate 
370Sstevel@tonic-gate #include	"defs.h"
380Sstevel@tonic-gate #include	"sym.h"
390Sstevel@tonic-gate 
400Sstevel@tonic-gate /*
410Sstevel@tonic-gate  * error messages
420Sstevel@tonic-gate  */
430Sstevel@tonic-gate #ifndef __STDC__
440Sstevel@tonic-gate #define const
450Sstevel@tonic-gate #endif
460Sstevel@tonic-gate 
470Sstevel@tonic-gate const char	badopt[]	= "bad option(s)";
480Sstevel@tonic-gate const char	mailmsg[]	= "you have mail\n";
490Sstevel@tonic-gate const char	nospace[]	= "no space";
500Sstevel@tonic-gate const char	nostack[]	= "no stack space";
510Sstevel@tonic-gate const char	synmsg[]	= "syntax error";
520Sstevel@tonic-gate 
530Sstevel@tonic-gate const char	badnum[]	= "bad number";
540Sstevel@tonic-gate const char	badsig[]	= "bad signal";
550Sstevel@tonic-gate const char	badid[]		= "invalid id";
560Sstevel@tonic-gate const char	badparam[]	= "parameter null or not set";
570Sstevel@tonic-gate const char	unset[]		= "parameter not set";
580Sstevel@tonic-gate const char	badsub[]	= "bad substitution";
590Sstevel@tonic-gate const char	badcreate[]	= "cannot create";
600Sstevel@tonic-gate const char	nofork[]	= "fork failed - too many processes";
610Sstevel@tonic-gate const char	noswap[]	= "cannot fork: no swap space";
620Sstevel@tonic-gate const char	restricted[]	= "restricted";
630Sstevel@tonic-gate const char	piperr[]	= "cannot make pipe";
640Sstevel@tonic-gate const char	badopen[]	= "cannot open";
650Sstevel@tonic-gate const char	coredump[]	= " - core dumped";
660Sstevel@tonic-gate const char	arglist[]	= "arg list too long";
670Sstevel@tonic-gate const char	txtbsy[]	= "text busy";
680Sstevel@tonic-gate const char	toobig[]	= "too big";
690Sstevel@tonic-gate const char	badexec[]	= "cannot execute";
700Sstevel@tonic-gate const char	notfound[]	= "not found";
710Sstevel@tonic-gate const char	badfile[]	= "bad file number";
720Sstevel@tonic-gate const char	badshift[]	= "cannot shift";
730Sstevel@tonic-gate const char	baddir[]	= "bad directory";
740Sstevel@tonic-gate const char	badtrap[]	= "bad trap";
750Sstevel@tonic-gate const char	wtfailed[]	= "is read only";
760Sstevel@tonic-gate const char	notid[]		= "is not an identifier";
771367Sakaplan const char 	badulimit[]	= "exceeds allowable limit";
780Sstevel@tonic-gate const char	badreturn[] 	= "cannot return when not in function";
790Sstevel@tonic-gate const char	badexport[] 	= "cannot export functions";
800Sstevel@tonic-gate const char	badunset[] 	= "cannot unset";
810Sstevel@tonic-gate const char	nohome[]	= "no home directory";
820Sstevel@tonic-gate const char 	badperm[]	= "execute permission denied";
830Sstevel@tonic-gate const char	longpwd[]	= "sh error: pwd too long";
840Sstevel@tonic-gate const char	mssgargn[]	= "missing arguments";
850Sstevel@tonic-gate const char	libacc[] 	= "can't access a needed shared library";
860Sstevel@tonic-gate const char	libbad[]	= "accessing a corrupted shared library";
870Sstevel@tonic-gate const char	libscn[]	= ".lib section in a.out corrupted";
880Sstevel@tonic-gate const char	libmax[]	= "attempting to link in too many libs";
89*2256Sna195498 const char	emultihop[]	= "Multihop attempted";
90*2256Sna195498 const char	nulldir[]	= "null directory";
91*2256Sna195498 const char	enotdir[]	= "not a directory";
92*2256Sna195498 const char	enoent[]	= "does not exist";
93*2256Sna195498 const char	eacces[]	= "permission denied";
94*2256Sna195498 const char	enolink[]	= "remote link inactive";
95*2256Sna195498 const char	exited[]	= "Done";
96*2256Sna195498 const char	running[]	= "Running";
97*2256Sna195498 const char	ambiguous[]	= "ambiguous";
98*2256Sna195498 const char	usage[]		= "usage";
99*2256Sna195498 const char	nojc[]		= "no job control";
100*2256Sna195498 const char	stopuse[]	= "stop id ...";
101*2256Sna195498 const char	ulimuse[]	= "ulimit [ -HSacdfnstv ] [ limit ]";
102*2256Sna195498 const char	killuse[]	= "kill [ [ -sig ] id ... | -l ]";
103*2256Sna195498 const char	jobsuse[]	= "jobs [ [ -l | -p ] [ id ... ] | -x cmd ]";
104*2256Sna195498 const char	nosuchjob[]	= "no such job";
105*2256Sna195498 const char	nosuchpid[]	= "no such process";
106*2256Sna195498 const char	nosuchpgid[]	= "no such process group";
107*2256Sna195498 const char	nocurjob[]	= "no current job";
108*2256Sna195498 const char	jobsstopped[]	= "there are stopped jobs";
109*2256Sna195498 const char	jobsrunning[]	= "there are running jobs";
110*2256Sna195498 const char	loginsh[]	= "cannot stop login shell";
111*2256Sna195498 const char	nlorsemi[]	= "newline or ;";
112*2256Sna195498 const char	signalnum[]	= "Signal ";
113*2256Sna195498 const char	badpwd[]	= "cannot determine current directory";
114*2256Sna195498 const char	badlocale[]	= "couldn't set locale correctly\n";
115*2256Sna195498 const char	nobracket[]	= "] missing";
116*2256Sna195498 const char	noparen[]	= ") expected";
117*2256Sna195498 const char	noarg[]		= "argument expected";
1180Sstevel@tonic-gate 
1190Sstevel@tonic-gate /*
1200Sstevel@tonic-gate  * messages for 'builtin' functions
1210Sstevel@tonic-gate  */
1220Sstevel@tonic-gate const char	btest[]		= "test";
1230Sstevel@tonic-gate const char	badop[]		= "unknown operator ";
1240Sstevel@tonic-gate /*
1250Sstevel@tonic-gate  * built in names
1260Sstevel@tonic-gate  */
1270Sstevel@tonic-gate const char	pathname[]	= "PATH";
1280Sstevel@tonic-gate const char	cdpname[]	= "CDPATH";
1290Sstevel@tonic-gate const char	homename[]	= "HOME";
1300Sstevel@tonic-gate const char	mailname[]	= "MAIL";
1310Sstevel@tonic-gate const char	ifsname[]	= "IFS";
1320Sstevel@tonic-gate const char	ps1name[]	= "PS1";
1330Sstevel@tonic-gate const char	ps2name[]	= "PS2";
1340Sstevel@tonic-gate const char	mchkname[]	= "MAILCHECK";
1350Sstevel@tonic-gate const char	acctname[]  	= "SHACCT";
1360Sstevel@tonic-gate const char	mailpname[]	= "MAILPATH";
1370Sstevel@tonic-gate 
1380Sstevel@tonic-gate /*
1390Sstevel@tonic-gate  * string constants
1400Sstevel@tonic-gate  */
1410Sstevel@tonic-gate const char	nullstr[]	= "";
1420Sstevel@tonic-gate const char	sptbnl[]	= " \t\n";
1430Sstevel@tonic-gate const char	defpath[]	= "/usr/bin:";
1440Sstevel@tonic-gate const char	colon[]		= ": ";
1450Sstevel@tonic-gate const char	minus[]		= "-";
1460Sstevel@tonic-gate const char	endoffile[]	= "end of file";
1470Sstevel@tonic-gate const char	unexpected[] 	= " unexpected";
1480Sstevel@tonic-gate const char	atline[]	= " at line ";
1490Sstevel@tonic-gate const char	devnull[]	= "/dev/null";
1500Sstevel@tonic-gate const char	execpmsg[]	= "+ ";
1510Sstevel@tonic-gate const char	readmsg[]	= "> ";
1520Sstevel@tonic-gate const char	stdprompt[]	= "$ ";
1530Sstevel@tonic-gate const char	supprompt[]	= "# ";
1540Sstevel@tonic-gate const char	profile[]	= ".profile";
1550Sstevel@tonic-gate const char	sysprofile[]	= "/etc/profile";
1560Sstevel@tonic-gate 
1570Sstevel@tonic-gate /*
1580Sstevel@tonic-gate  * locale testing
1590Sstevel@tonic-gate  */
1600Sstevel@tonic-gate const char	localedir[]	= "/usr/lib/locale";
1610Sstevel@tonic-gate int		localedir_exists;
1620Sstevel@tonic-gate 
1630Sstevel@tonic-gate /*
1640Sstevel@tonic-gate  * tables
1650Sstevel@tonic-gate  */
1660Sstevel@tonic-gate 
1670Sstevel@tonic-gate const struct sysnod reserved[] =
1680Sstevel@tonic-gate {
1690Sstevel@tonic-gate 	{ "case",	CASYM	},
1700Sstevel@tonic-gate 	{ "do",		DOSYM	},
1710Sstevel@tonic-gate 	{ "done",	ODSYM	},
1720Sstevel@tonic-gate 	{ "elif",	EFSYM	},
1730Sstevel@tonic-gate 	{ "else",	ELSYM	},
1740Sstevel@tonic-gate 	{ "esac",	ESSYM	},
1750Sstevel@tonic-gate 	{ "fi",		FISYM	},
1760Sstevel@tonic-gate 	{ "for",	FORSYM	},
1770Sstevel@tonic-gate 	{ "if",		IFSYM	},
1780Sstevel@tonic-gate 	{ "in",		INSYM	},
1790Sstevel@tonic-gate 	{ "then",	THSYM	},
1800Sstevel@tonic-gate 	{ "until",	UNSYM	},
1810Sstevel@tonic-gate 	{ "while",	WHSYM	},
1820Sstevel@tonic-gate 	{ "{",		BRSYM	},
1830Sstevel@tonic-gate 	{ "}",		KTSYM	}
1840Sstevel@tonic-gate };
1850Sstevel@tonic-gate 
1860Sstevel@tonic-gate const int no_reserved = sizeof(reserved)/sizeof(struct sysnod);
1870Sstevel@tonic-gate 
1880Sstevel@tonic-gate const char	export[] = "export";
1890Sstevel@tonic-gate const char	readonly[] = "readonly";
1900Sstevel@tonic-gate 
1910Sstevel@tonic-gate 
1920Sstevel@tonic-gate const struct sysnod commands[] =
1930Sstevel@tonic-gate {
1940Sstevel@tonic-gate 	{ ".",		SYSDOT	},
1950Sstevel@tonic-gate 	{ ":",		SYSNULL	},
1960Sstevel@tonic-gate 
1970Sstevel@tonic-gate #ifndef RES
1980Sstevel@tonic-gate 	{ "[",		SYSTST },
1990Sstevel@tonic-gate #endif
2000Sstevel@tonic-gate 	{ "bg",		SYSFGBG },
2010Sstevel@tonic-gate 	{ "break",	SYSBREAK },
2020Sstevel@tonic-gate 	{ "cd",		SYSCD	},
2030Sstevel@tonic-gate 	{ "chdir",	SYSCD	},
2040Sstevel@tonic-gate 	{ "continue",	SYSCONT	},
2050Sstevel@tonic-gate 	{ "echo",	SYSECHO },
2060Sstevel@tonic-gate 	{ "eval",	SYSEVAL	},
2070Sstevel@tonic-gate 	{ "exec",	SYSEXEC	},
2080Sstevel@tonic-gate 	{ "exit",	SYSEXIT	},
2090Sstevel@tonic-gate 	{ "export",	SYSXPORT },
2100Sstevel@tonic-gate 	{ "fg",		SYSFGBG },
2110Sstevel@tonic-gate 	{ "getopts",	SYSGETOPT },
2120Sstevel@tonic-gate 	{ "hash",	SYSHASH	},
2130Sstevel@tonic-gate 	{ "jobs",	SYSJOBS },
2140Sstevel@tonic-gate 	{ "kill",	SYSKILL },
2150Sstevel@tonic-gate #ifdef RES
2160Sstevel@tonic-gate 	{ "login",	SYSLOGIN },
2170Sstevel@tonic-gate 	{ "newgrp",	SYSLOGIN },
2180Sstevel@tonic-gate #else
2190Sstevel@tonic-gate 	{ "newgrp",	SYSNEWGRP },
2200Sstevel@tonic-gate #endif
2210Sstevel@tonic-gate 
2220Sstevel@tonic-gate 	{ "pwd",	SYSPWD },
2230Sstevel@tonic-gate 	{ "read",	SYSREAD	},
2240Sstevel@tonic-gate 	{ "readonly",	SYSRDONLY },
2250Sstevel@tonic-gate 	{ "return",	SYSRETURN },
2260Sstevel@tonic-gate 	{ "set",	SYSSET	},
2270Sstevel@tonic-gate 	{ "shift",	SYSSHFT	},
2280Sstevel@tonic-gate 	{ "stop",	SYSSTOP	},
2290Sstevel@tonic-gate 	{ "suspend",	SYSSUSP},
2300Sstevel@tonic-gate 	{ "test",	SYSTST },
2310Sstevel@tonic-gate 	{ "times",	SYSTIMES },
2320Sstevel@tonic-gate 	{ "trap",	SYSTRAP	},
2330Sstevel@tonic-gate 	{ "type",	SYSTYPE },
2340Sstevel@tonic-gate 
2350Sstevel@tonic-gate 
2360Sstevel@tonic-gate #ifndef RES
2370Sstevel@tonic-gate 	{ "ulimit",	SYSULIMIT },
2380Sstevel@tonic-gate 	{ "umask",	SYSUMASK },
2390Sstevel@tonic-gate #endif
2400Sstevel@tonic-gate 
2410Sstevel@tonic-gate 	{ "unset", 	SYSUNS },
2420Sstevel@tonic-gate 	{ "wait",	SYSWAIT	}
2430Sstevel@tonic-gate };
2440Sstevel@tonic-gate 
2450Sstevel@tonic-gate const int no_commands = sizeof(commands)/sizeof(struct sysnod);
2460Sstevel@tonic-gate 
247