1 /***********************************************************************
2 *                                                                      *
3 *               This software is part of the ast package               *
4 *          Copyright (c) 1982-2012 AT&T Intellectual Property          *
5 *                      and is licensed under the                       *
6 *                 Eclipse Public License, Version 1.0                  *
7 *                    by AT&T Intellectual Property                     *
8 *                                                                      *
9 *                A copy of the License is available at                 *
10 *          http://www.eclipse.org/org/documents/epl-v10.html           *
11 *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         *
12 *                                                                      *
13 *              Information and Software Systems Research               *
14 *                            AT&T Research                             *
15 *                           Florham Park NJ                            *
16 *                                                                      *
17 *                  David Korn <dgk@research.att.com>                   *
18 *                                                                      *
19 ***********************************************************************/
20 #pragma prototyped
21 /*
22  *	UNIX shell
23  *	S. R. Bourne
24  *	Rewritten by David Korn
25  *
26  *	AT&T Labs
27  *
28  */
29 
30 #include	<ast.h>
31 #include	<errno.h>
32 #include	"defs.h"
33 #include	"path.h"
34 #include	"io.h"
35 #include	"shlex.h"
36 #include	"timeout.h"
37 #include	"history.h"
38 #include	"builtins.h"
39 #include	"jobs.h"
40 #include	"edit.h"
41 
42 #include	"FEATURE/cmds"
43 
44 /* error messages */
45 const char e_timewarn[]		= "\r\n\ashell will timeout in 60 seconds due to inactivity";
46 const char e_runvi[]		= "\\hist -e \"${VISUAL:-${EDITOR:-vi}}\" ";
47 const char e_timeout[]		= "timed out waiting for input";
48 const char e_mailmsg[]		= "you have mail in $_";
49 const char e_query[]		= "no query process";
50 const char e_history[]		= "no history file";
51 const char e_histopen[]		= "history file cannot open";
52 const char e_option[]		= "%s: bad option(s)";
53 const char e_toomany[]		= "open file limit exceeded";
54 const char e_argtype[]		= "invalid argument of type %c";
55 const char e_oneoperand[]	= "one operand expected";
56 const char e_formspec[]		= "%c: unknown format specifier";
57 const char e_badregexp[]	= "%s: invalid regular expression";
58 const char e_number[]		= "%s: bad number";
59 const char e_badlocale[]	= "%s: unknown locale";
60 const char e_nullset[]		= "%s: parameter null";
61 const char e_notset[]		= "%s: parameter not set";
62 const char e_noparent[]		= "%s: no parent";
63 const char e_subst[]		= "%s: bad substitution";
64 const char e_create[]		= "%s: cannot create";
65 const char e_tmpcreate[]	= "cannot create temporary file";
66 const char e_restricted[]	= "%s: restricted";
67 const char e_pfsh[]		= "%s: disabled in profile shell";
68 const char e_pexists[]		= "process already exists";
69 const char e_exists[]		= "%s: file already exists";
70 const char e_pipe[]		= "cannot create pipe";
71 const char e_alarm[]		= "cannot set alarm";
72 const char e_open[]		= "%s: cannot open";
73 const char e_notseek[]		= "%s: not seekable";
74 const char e_badseek[]		= "%s: invalid seek offset";
75 const char e_badpattern[]	= "%s: invalid shell pattern";
76 const char e_noread[]		= "%s: pattern seek requires read access";
77 const char e_logout[]		= "Use 'exit' to terminate this shell";
78 const char e_exec[]		= "%s: cannot execute";
79 const char e_pwd[]		= "cannot access parent directories";
80 const char e_found[]		= "%s: not found";
81 const char e_defined[]		= "%s: function not defined";
82 const char e_nointerp[]		= "%s: interpreter not found";
83 const char e_subscript[]	= "%s: subscript out of range";
84 const char e_toodeep[]		= "%s: recursion too deep";
85 const char e_access[]		= "permission denied";
86 #ifdef _cmd_universe
87     const char e_nouniverse[]	= "universe not accessible";
88 #endif /* _cmd_universe */
89 const char e_direct[]		= "bad directory";
90 const char e_file[]		= "%s: bad file unit number";
91 const char e_redirect[]		= "redirection failed";
92 const char e_trap[]		= "%s: bad trap";
93 const char e_readonly[]		= "%s: is read only";
94 const char e_badfield[]		= "%d: negative field size";
95 const char e_ident[]		= "%s: is not an identifier";
96 const char e_badname[]		= "%s: invalid name";
97 const char e_varname[]		= "%s: invalid variable name";
98 const char e_badfun[]		= "%s: invalid function name";
99 const char e_aliname[]		= "%s: invalid alias name";
100 const char e_badexport[]	= "%s: only simple variables can be exported";
101 const char e_badref[]		= "%s: reference variable cannot be an array";
102 const char e_badsubscript[]	= "%c: invalid subscript in assignment";
103 const char e_noarray[]		= "%s: cannot be an array";
104 const char e_badappend[]	= "%s: invalid append to associative array";
105 const char e_noref[]		= "%s: no reference name";
106 const char e_nounattr[]		= "cannot unset attribute C or A or a";
107 const char e_selfref[]		= "%s: invalid self reference";
108 const char e_globalref[]	= "%s: global reference cannot refer to local variable";
109 const char e_noalias[]		= "%s: alias not found\n";
110 const char e_format[]		= "%s: bad format";
111 const char e_redef[]		= "%s: type cannot be redefined";
112 const char e_required[]		= "%s: is a required element of %s";
113 const char e_badtformat[]	= "%c: bad format character in time format";
114 const char e_nolabels[]		= "%s: label not implemented";
115 const char e_notimp[]		= "%s: not implemented";
116 const char e_notelem[]		= "%.*s: is not an element of %s";
117 const char e_notenum[]		= "%s: not an enumeration type";
118 const char e_unknowntype[]	= "%.*s: unknown type";
119 const char e_unknownmap[]	= "%s: unknown mapping name";
120 const char e_mapchararg[]	= "-M requires argument when operands are specified";
121 const char e_subcomvar[]	= "%s: compound assignment requires sub-variable name";
122 const char e_badtypedef[]	= "%s: type definition requires compound assignment";
123 const char e_typecompat[]	= "%s:  array instance incompatible with type assignment";
124 const char e_nosupport[]	= "not supported";
125 const char e_badrange[]		= "%d-%d: invalid range";
126 const char e_eneedsarg[]	= "-e - requires single argument";
127 const char e_badbase[]		= "%s unknown base";
128 const char e_loop[]		= "%s: would cause loop";
129 const char e_overlimit[]	= "%s: limit exceeded";
130 const char e_badsyntax[]	= "incorrect syntax";
131 const char e_badwrite[]		= "write to %d failed";
132 const char e_staticfun[]	= "%s: defined as a static function in type %s and cannot be redefined";
133 const char e_on	[]		= "on";
134 const char e_off[]		= "off";
135 const char is_reserved[]	= " is a keyword";
136 const char is_builtin[]		= " is a shell builtin";
137 const char is_spcbuiltin[]	= " is a special shell builtin";
138 const char is_builtver[]	= "is a shell builtin version of";
139 const char is_alias[]		= "%s is an alias for ";
140 const char is_xalias[]		= "%s is an exported alias for ";
141 const char is_talias[]		= "is a tracked alias for";
142 const char is_function[]	= " is a function";
143 const char is_ufunction[]	= " is an undefined function";
144 #ifdef JOBS
145 #   ifdef SIGTSTP
146 	const char e_newtty[]	= "Switching to new tty driver...";
147 	const char e_oldtty[]	= "Reverting to old tty driver...";
148 	const char e_no_start[]	= "Cannot start job control";
149 #   endif /*SIGTSTP */
150     const char e_no_jctl[]	= "No job control";
151     const char e_terminate[]	= "You have stopped jobs";
152     const char e_done[]		= " Done";
153     const char e_nlspace[]	= "\n      ";
154     const char e_running[]	= " Running";
155     const char e_ambiguous[]	= "%s: Ambiguous";
156     const char e_jobsrunning[]	= "You have running jobs";
157     const char e_no_job[]	= "no such job";
158     const char e_no_proc[]	= "no such process";
159     const char e_badpid[]	= "%s: invalid process id";
160 #   if SHOPT_COSHELL
161         const char e_jobusage[]	= "%s: Arguments must be %%job, process ids, or job pool names";
162 #   else
163         const char e_jobusage[]	= "%s: Arguments must be %%job or process ids";
164 #   endif /* SHOPT_COSHELL */
165 #endif /* JOBS */
166 const char e_coredump[]		= "(coredump)";
167 const char e_alphanum[]		= "[_[:alpha:]]*([_[:alnum:]])";
168 const char e_devfdNN[]		= "/dev/fd/+([0-9])";
169 const char e_devfdstd[]		= "/dev/@(fd/+([0-9])|std@(in|out|err))";
170 const char e_signo[]		= "Signal %d";
171 #if SHOPT_FS_3D
172     const char e_cantget[]	= "cannot get %s";
173     const char e_cantset[]	= "cannot set %s";
174     const char e_mapping[]	= "mapping";
175     const char e_versions[]	= "versions";
176 #endif /* SHOPT_FS_3D */
177 
178 /* string constants */
179 const char e_heading[]		= "Current option settings";
180 const char e_sptbnl[]		= " \t\n";
181 const char e_tolower[]		= "tolower";
182 const char e_toupper[]		= "toupper";
183 const char e_defpath[]		= "/bin:/usr/bin:";
184 const char e_defedit[]		= _pth_ed;
185 const char e_unknown []		= "<command unknown>";
186 const char e_devnull[]		= "/dev/null";
187 const char e_traceprompt[]	= "+ ";
188 const char e_supprompt[]	= "# ";
189 const char e_stdprompt[]	= "$ ";
190 const char e_profile[]		= "$HOME/.profile";
191 const char e_sysprofile[]	= "/etc/profile";
192 const char e_suidprofile[]	= "/etc/suid_profile";
193 #if SHOPT_SYSRC
194 const char e_sysrc[]		= "/etc/ksh.kshrc";
195 #endif
196 #if SHOPT_BASH
197 #if SHOPT_SYSRC
198 const char e_bash_sysrc[]	= "/etc/bash.bashrc";
199 #endif
200 const char e_bash_rc[]		= "$HOME/.bashrc";
201 const char e_bash_login[]	= "$HOME/.bash_login";
202 const char e_bash_logout[]	= "$HOME/.bash_logout";
203 const char e_bash_profile[]	= "$HOME/.bash_profile";
204 #endif
205 const char e_crondir[]		= "/usr/spool/cron/atjobs";
206 const char e_prohibited[]	= "login setuid/setgid shells prohibited";
207 #if SHOPT_SUID_EXEC
208    const char e_suidexec[]	= "/etc/suid_exec";
209 #endif /* SHOPT_SUID_EXEC */
210 const char hist_fname[]		= "/.sh_history";
211 const char e_dot[]		= ".";
212 const char e_envmarker[]	= "A__z";
213 const char e_timeformat[]	= "\nreal\t%2lR\nuser\t%2lU\nsys\t%2lS";
214 const char e_dict[]		= "libshell";
215 const char e_funload[]		= "function, built-in or type definition for %s not found in %s";
216