1 | /* $Header: /afs/dev.mit.edu/source/repository/third/tcsh/sh.err.c,v 1.1.1.2 1998-10-03 21:09:58 danw Exp $ */ |
---|
2 | /* |
---|
3 | * sh.err.c: Error printing routines. |
---|
4 | */ |
---|
5 | /*- |
---|
6 | * Copyright (c) 1980, 1991 The Regents of the University of California. |
---|
7 | * All rights reserved. |
---|
8 | * |
---|
9 | * Redistribution and use in source and binary forms, with or without |
---|
10 | * modification, are permitted provided that the following conditions |
---|
11 | * are met: |
---|
12 | * 1. Redistributions of source code must retain the above copyright |
---|
13 | * notice, this list of conditions and the following disclaimer. |
---|
14 | * 2. Redistributions in binary form must reproduce the above copyright |
---|
15 | * notice, this list of conditions and the following disclaimer in the |
---|
16 | * documentation and/or other materials provided with the distribution. |
---|
17 | * 3. All advertising materials mentioning features or use of this software |
---|
18 | * must display the following acknowledgement: |
---|
19 | * This product includes software developed by the University of |
---|
20 | * California, Berkeley and its contributors. |
---|
21 | * 4. Neither the name of the University nor the names of its contributors |
---|
22 | * may be used to endorse or promote products derived from this software |
---|
23 | * without specific prior written permission. |
---|
24 | * |
---|
25 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
---|
26 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
28 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
---|
29 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
---|
30 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
---|
31 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
---|
32 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
---|
33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
---|
34 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
---|
35 | * SUCH DAMAGE. |
---|
36 | */ |
---|
37 | #define _h_sh_err /* Don't redefine the errors */ |
---|
38 | #include "sh.h" |
---|
39 | |
---|
40 | RCSID("$Id: sh.err.c,v 1.1.1.2 1998-10-03 21:09:58 danw Exp $") |
---|
41 | |
---|
42 | /* |
---|
43 | * C Shell |
---|
44 | */ |
---|
45 | |
---|
46 | #ifdef lint |
---|
47 | #undef va_arg |
---|
48 | #define va_arg(a, b) (a ? (b) 0 : (b) 0) |
---|
49 | #endif |
---|
50 | |
---|
51 | char *seterr = NULL; /* Holds last error if there was one */ |
---|
52 | |
---|
53 | #define ERR_FLAGS 0xf0000000 |
---|
54 | #define ERR_NAME 0x10000000 |
---|
55 | #define ERR_SILENT 0x20000000 |
---|
56 | #define ERR_OLD 0x40000000 |
---|
57 | |
---|
58 | #define ERR_SYNTAX 0 |
---|
59 | #define ERR_NOTALLOWED 1 |
---|
60 | #define ERR_WTOOLONG 2 |
---|
61 | #define ERR_LTOOLONG 3 |
---|
62 | #define ERR_DOLZERO 4 |
---|
63 | #define ERR_INCBR 5 |
---|
64 | #define ERR_EXPORD 6 |
---|
65 | #define ERR_BADMOD 7 |
---|
66 | #define ERR_SUBSCRIPT 8 |
---|
67 | #define ERR_BADNUM 9 |
---|
68 | #define ERR_NOMORE 10 |
---|
69 | #define ERR_FILENAME 11 |
---|
70 | #define ERR_GLOB 12 |
---|
71 | #define ERR_COMMAND 13 |
---|
72 | #define ERR_TOOFEW 14 |
---|
73 | #define ERR_TOOMANY 15 |
---|
74 | #define ERR_DANGER 16 |
---|
75 | #define ERR_EMPTYIF 17 |
---|
76 | #define ERR_IMPRTHEN 18 |
---|
77 | #define ERR_NOPAREN 19 |
---|
78 | #define ERR_NOTFOUND 20 |
---|
79 | #define ERR_MASK 21 |
---|
80 | #define ERR_LIMIT 22 |
---|
81 | #define ERR_TOOLARGE 23 |
---|
82 | #define ERR_SCALEF 24 |
---|
83 | #define ERR_UNDVAR 25 |
---|
84 | #define ERR_DEEP 26 |
---|
85 | #define ERR_BADSIG 27 |
---|
86 | #define ERR_UNKSIG 28 |
---|
87 | #define ERR_VARBEGIN 29 |
---|
88 | #define ERR_VARTOOLONG 30 |
---|
89 | #define ERR_VARALNUM 31 |
---|
90 | #define ERR_JOBCONTROL 32 |
---|
91 | #define ERR_EXPRESSION 33 |
---|
92 | #define ERR_NOHOMEDIR 34 |
---|
93 | #define ERR_CANTCHANGE 35 |
---|
94 | #define ERR_NULLCOM 36 |
---|
95 | #define ERR_ASSIGN 37 |
---|
96 | #define ERR_UNKNOWNOP 38 |
---|
97 | #define ERR_AMBIG 39 |
---|
98 | #define ERR_EXISTS 40 |
---|
99 | #define ERR_ARGC 41 |
---|
100 | #define ERR_INTR 42 |
---|
101 | #define ERR_RANGE 43 |
---|
102 | #define ERR_OVERFLOW 44 |
---|
103 | #define ERR_NOSUCHJOB 45 |
---|
104 | #define ERR_TERMINAL 46 |
---|
105 | #define ERR_NOTWHILE 47 |
---|
106 | #define ERR_NOPROC 48 |
---|
107 | #define ERR_NOMATCH 49 |
---|
108 | #define ERR_MISSING 50 |
---|
109 | #define ERR_UNMATCHED 51 |
---|
110 | #define ERR_NOMEM 52 |
---|
111 | #define ERR_PIPE 53 |
---|
112 | #define ERR_SYSTEM 54 |
---|
113 | #define ERR_STRING 55 |
---|
114 | #define ERR_JOBS 56 |
---|
115 | #define ERR_JOBARGS 57 |
---|
116 | #define ERR_JOBCUR 58 |
---|
117 | #define ERR_JOBPREV 59 |
---|
118 | #define ERR_JOBPAT 60 |
---|
119 | #define ERR_NESTING 61 |
---|
120 | #define ERR_JOBCTRLSUB 62 |
---|
121 | #define ERR_SYNC 63 |
---|
122 | #define ERR_STOPPED 64 |
---|
123 | #define ERR_NODIR 65 |
---|
124 | #define ERR_EMPTY 66 |
---|
125 | #define ERR_BADDIR 67 |
---|
126 | #define ERR_DIRUS 68 |
---|
127 | #define ERR_HFLAG 69 |
---|
128 | #define ERR_NOTLOGIN 70 |
---|
129 | #define ERR_DIV0 71 |
---|
130 | #define ERR_MOD0 72 |
---|
131 | #define ERR_BADSCALE 73 |
---|
132 | #define ERR_SUSPLOG 74 |
---|
133 | #define ERR_UNKUSER 75 |
---|
134 | #define ERR_NOHOME 76 |
---|
135 | #define ERR_HISTUS 77 |
---|
136 | #define ERR_SPDOLLT 78 |
---|
137 | #define ERR_NEWLINE 79 |
---|
138 | #define ERR_SPSTAR 80 |
---|
139 | #define ERR_DIGIT 81 |
---|
140 | #define ERR_VARILL 82 |
---|
141 | #define ERR_NLINDEX 83 |
---|
142 | #define ERR_EXPOVFL 84 |
---|
143 | #define ERR_VARSYN 85 |
---|
144 | #define ERR_BADBANG 86 |
---|
145 | #define ERR_NOSUBST 87 |
---|
146 | #define ERR_BADSUBST 88 |
---|
147 | #define ERR_LHS 89 |
---|
148 | #define ERR_RHSLONG 90 |
---|
149 | #define ERR_BADBANGMOD 91 |
---|
150 | #define ERR_MODFAIL 92 |
---|
151 | #define ERR_SUBOVFL 93 |
---|
152 | #define ERR_BADBANGARG 94 |
---|
153 | #define ERR_NOSEARCH 95 |
---|
154 | #define ERR_NOEVENT 96 |
---|
155 | #define ERR_TOOMANYRP 97 |
---|
156 | #define ERR_TOOMANYLP 98 |
---|
157 | #define ERR_BADPLP 99 |
---|
158 | #define ERR_MISRED 100 |
---|
159 | #define ERR_OUTRED 101 |
---|
160 | #define ERR_REDPAR 102 |
---|
161 | #define ERR_INRED 103 |
---|
162 | #define ERR_BADPLPS 104 |
---|
163 | #define ERR_ALIASLOOP 105 |
---|
164 | #define ERR_NOWATCH 106 |
---|
165 | #define ERR_NOSCHED 107 |
---|
166 | #define ERR_SCHEDUSAGE 108 |
---|
167 | #define ERR_SCHEDEV 109 |
---|
168 | #define ERR_SCHEDCOM 110 |
---|
169 | #define ERR_SCHEDTIME 111 |
---|
170 | #define ERR_SCHEDREL 112 |
---|
171 | #define ERR_TCNOSTR 113 |
---|
172 | #define ERR_SETTCUS 114 |
---|
173 | #define ERR_TCCAP 115 |
---|
174 | #define ERR_TCPARM 116 |
---|
175 | #define ERR_TCARGS 117 |
---|
176 | #define ERR_TCNARGS 118 |
---|
177 | #define ERR_TCUSAGE 119 |
---|
178 | #define ERR_ARCH 120 |
---|
179 | #define ERR_HISTLOOP 121 |
---|
180 | #define ERR_FILEINQ 122 |
---|
181 | #define ERR_SELOVFL 123 |
---|
182 | #define ERR_TCSHUSAGE 124 |
---|
183 | #define ERR_COMPCOM 125 |
---|
184 | #define ERR_COMPINV 126 |
---|
185 | #define ERR_COMPMIS 127 |
---|
186 | #define ERR_COMPINC 128 |
---|
187 | #define ERR_MFLAG 129 |
---|
188 | #define ERR_ULIMUS 130 |
---|
189 | #define ERR_READONLY 131 |
---|
190 | #define ERR_BADJOB 132 |
---|
191 | #define ERR_INVALID 133 |
---|
192 | #define ERR_BADCOLORVAR 134 |
---|
193 | #define NO_ERRORS 135 |
---|
194 | |
---|
195 | static char *elst[NO_ERRORS] INIT_ZERO_STRUCT; |
---|
196 | |
---|
197 | /* |
---|
198 | * Init the elst depending on the locale |
---|
199 | */ |
---|
200 | void |
---|
201 | errinit() |
---|
202 | { |
---|
203 | #ifdef NLS_CATALOGS |
---|
204 | int i; |
---|
205 | |
---|
206 | for (i = 0; i < NO_ERRORS; i++) |
---|
207 | xfree((ptr_t) elst[i]); |
---|
208 | #endif |
---|
209 | |
---|
210 | elst[ERR_SYNTAX] = CSAVS(1, 1, "Syntax Error"); |
---|
211 | elst[ERR_NOTALLOWED] = CSAVS(1, 2, "%s is not allowed"); |
---|
212 | elst[ERR_WTOOLONG] = CSAVS(1, 3, "Word too long"); |
---|
213 | elst[ERR_LTOOLONG] = CSAVS(1, 4, "$< line too long"); |
---|
214 | elst[ERR_DOLZERO] = CSAVS(1, 5, "No file for $0"); |
---|
215 | elst[ERR_INCBR] = CSAVS(1, 6, "Incomplete [] modifier"); |
---|
216 | elst[ERR_EXPORD] = CSAVS(1, 7, "$ expansion must end before ]"); |
---|
217 | elst[ERR_BADMOD] = CSAVS(1, 8, "Bad : modifier in $ (%c)"); |
---|
218 | elst[ERR_SUBSCRIPT] = CSAVS(1, 9, "Subscript error"); |
---|
219 | elst[ERR_BADNUM] = CSAVS(1, 10, "Badly formed number"); |
---|
220 | elst[ERR_NOMORE] = CSAVS(1, 11, "No more words"); |
---|
221 | elst[ERR_FILENAME] = CSAVS(1, 12, "Missing file name"); |
---|
222 | elst[ERR_GLOB] = CSAVS(1, 13, "Internal glob error"); |
---|
223 | elst[ERR_COMMAND] = CSAVS(1, 14, "Command not found"); |
---|
224 | elst[ERR_TOOFEW] = CSAVS(1, 15, "Too few arguments"); |
---|
225 | elst[ERR_TOOMANY] = CSAVS(1, 16, "Too many arguments"); |
---|
226 | elst[ERR_DANGER] = CSAVS(1, 17, "Too dangerous to alias that"); |
---|
227 | elst[ERR_EMPTYIF] = CSAVS(1, 18, "Empty if"); |
---|
228 | elst[ERR_IMPRTHEN] = CSAVS(1, 19, "Improper then"); |
---|
229 | elst[ERR_NOPAREN] = CSAVS(1, 20, "Words not parenthesized"); |
---|
230 | elst[ERR_NOTFOUND] = CSAVS(1, 21, "%s not found"); |
---|
231 | elst[ERR_MASK] = CSAVS(1, 22, "Improper mask"); |
---|
232 | elst[ERR_LIMIT] = CSAVS(1, 23, "No such limit"); |
---|
233 | elst[ERR_TOOLARGE] = CSAVS(1, 24, "Argument too large"); |
---|
234 | elst[ERR_SCALEF] = CSAVS(1, 25, "Improper or unknown scale factor"); |
---|
235 | elst[ERR_UNDVAR] = CSAVS(1, 26, "Undefined variable"); |
---|
236 | elst[ERR_DEEP] = CSAVS(1, 27, "Directory stack not that deep"); |
---|
237 | elst[ERR_BADSIG] = CSAVS(1, 28, "Bad signal number"); |
---|
238 | elst[ERR_UNKSIG] = CSAVS(1, 29, "Unknown signal; kill -l lists signals"); |
---|
239 | elst[ERR_VARBEGIN] = CSAVS(1, 30, "Variable name must begin with a letter"); |
---|
240 | elst[ERR_VARTOOLONG] = CSAVS(1, 31, "Variable name too long"); |
---|
241 | elst[ERR_VARALNUM] = CSAVS(1, 32, |
---|
242 | "Variable name must contain alphanumeric characters"); |
---|
243 | elst[ERR_JOBCONTROL] = CSAVS(1, 33, "No job control in this shell"); |
---|
244 | elst[ERR_EXPRESSION] = CSAVS(1, 34, "Expression Syntax"); |
---|
245 | elst[ERR_NOHOMEDIR] = CSAVS(1, 35, "No home directory"); |
---|
246 | elst[ERR_CANTCHANGE] = CSAVS(1, 36, "Can't change to home directory"); |
---|
247 | elst[ERR_NULLCOM] = CSAVS(1, 37, "Invalid null command"); |
---|
248 | elst[ERR_ASSIGN] = CSAVS(1, 38, "Assignment missing expression"); |
---|
249 | elst[ERR_UNKNOWNOP] = CSAVS(1, 39, "Unknown operator"); |
---|
250 | elst[ERR_AMBIG] = CSAVS(1, 40, "Ambiguous"); |
---|
251 | elst[ERR_EXISTS] = CSAVS(1, 41, "%s: File exists"); |
---|
252 | elst[ERR_ARGC] = CSAVS(1, 42, "Argument for -c ends in backslash"); |
---|
253 | elst[ERR_INTR] = CSAVS(1, 43, "Interrupted"); |
---|
254 | elst[ERR_RANGE] = CSAVS(1, 44, "Subscript out of range"); |
---|
255 | elst[ERR_OVERFLOW] = CSAVS(1, 45, "Line overflow"); |
---|
256 | elst[ERR_NOSUCHJOB] = CSAVS(1, 46, "No such job"); |
---|
257 | elst[ERR_TERMINAL] = CSAVS(1, 47, "Can't from terminal"); |
---|
258 | elst[ERR_NOTWHILE] = CSAVS(1, 48, "Not in while/foreach"); |
---|
259 | elst[ERR_NOPROC] = CSAVS(1, 49, "No more processes"); |
---|
260 | elst[ERR_NOMATCH] = CSAVS(1, 50, "No match"); |
---|
261 | elst[ERR_MISSING] = CSAVS(1, 51, "Missing %c"); |
---|
262 | elst[ERR_UNMATCHED] = CSAVS(1, 52, "Unmatched %c"); |
---|
263 | elst[ERR_NOMEM] = CSAVS(1, 53, "Out of memory"); |
---|
264 | elst[ERR_PIPE] = CSAVS(1, 54, "Can't make pipe"); |
---|
265 | elst[ERR_SYSTEM] = CSAVS(1, 55, "%s: %s"); |
---|
266 | elst[ERR_STRING] = CSAVS(1, 56, "%s"); |
---|
267 | elst[ERR_JOBS] = CSAVS(1, 57, "Usage: jobs [ -l ]"); |
---|
268 | elst[ERR_JOBARGS] = CSAVS(1, 58, "Arguments should be jobs or process id's"); |
---|
269 | elst[ERR_JOBCUR] = CSAVS(1, 59, "No current job"); |
---|
270 | elst[ERR_JOBPREV] = CSAVS(1, 60, "No previous job"); |
---|
271 | elst[ERR_JOBPAT] = CSAVS(1, 61, "No job matches pattern"); |
---|
272 | elst[ERR_NESTING] = CSAVS(1, 62, "Fork nesting > %d; maybe `...` loop"); |
---|
273 | elst[ERR_JOBCTRLSUB] = CSAVS(1, 63, "No job control in subshells"); |
---|
274 | elst[ERR_SYNC] = CSAVS(1, 64, "Sync fault: Process %d not found"); |
---|
275 | elst[ERR_STOPPED] = |
---|
276 | #ifdef SUSPENDED |
---|
277 | CSAVS(1, 65, "%sThere are suspended jobs"); |
---|
278 | #else |
---|
279 | CSAVS(1, 66, "%sThere are stopped jobs"); |
---|
280 | #endif /* SUSPENDED */ |
---|
281 | elst[ERR_NODIR] = CSAVS(1, 67, "No other directory"); |
---|
282 | elst[ERR_EMPTY] = CSAVS(1, 68, "Directory stack empty"); |
---|
283 | elst[ERR_BADDIR] = CSAVS(1, 69, "Bad directory"); |
---|
284 | elst[ERR_DIRUS] = CSAVS(1, 70, "Usage: %s [-%s]%s"); |
---|
285 | elst[ERR_HFLAG] = CSAVS(1, 71, "No operand for -h flag"); |
---|
286 | elst[ERR_NOTLOGIN] = CSAVS(1, 72, "Not a login shell"); |
---|
287 | elst[ERR_DIV0] = CSAVS(1, 73, "Division by 0"); |
---|
288 | elst[ERR_MOD0] = CSAVS(1, 74, "Mod by 0"); |
---|
289 | elst[ERR_BADSCALE] = CSAVS(1, 75, "Bad scaling; did you mean \"%s\"?"); |
---|
290 | elst[ERR_SUSPLOG] = CSAVS(1, 76, "Can't suspend a login shell (yet)"); |
---|
291 | elst[ERR_UNKUSER] = CSAVS(1, 77, "Unknown user: %s"); |
---|
292 | elst[ERR_NOHOME] = CSAVS(1, 78, "No $home variable set"); |
---|
293 | elst[ERR_HISTUS] = CSAVS(1, 79, |
---|
294 | "Usage: history [-%s] [# number of events]"); |
---|
295 | elst[ERR_SPDOLLT] = CSAVS(1, 80, "$, ! or < not allowed with $# or $?"); |
---|
296 | elst[ERR_NEWLINE] = CSAVS(1, 81, "Newline in variable name"); |
---|
297 | elst[ERR_SPSTAR] = CSAVS(1, 82, "* not allowed with $# or $?"); |
---|
298 | elst[ERR_DIGIT] = CSAVS(1, 83, "$?<digit> or $#<digit> not allowed"); |
---|
299 | elst[ERR_VARILL] = CSAVS(1, 84, "Illegal variable name"); |
---|
300 | elst[ERR_NLINDEX] = CSAVS(1, 85, "Newline in variable index"); |
---|
301 | elst[ERR_EXPOVFL] = CSAVS(1, 86, "Expansion buffer overflow"); |
---|
302 | elst[ERR_VARSYN] = CSAVS(1, 87, "Variable syntax"); |
---|
303 | elst[ERR_BADBANG] = CSAVS(1, 88, "Bad ! form"); |
---|
304 | elst[ERR_NOSUBST] = CSAVS(1, 89, "No previous substitute"); |
---|
305 | elst[ERR_BADSUBST] = CSAVS(1, 90, "Bad substitute"); |
---|
306 | elst[ERR_LHS] = CSAVS(1, 91, "No previous left hand side"); |
---|
307 | elst[ERR_RHSLONG] = CSAVS(1, 92, "Right hand side too long"); |
---|
308 | elst[ERR_BADBANGMOD] = CSAVS(1, 93, "Bad ! modifier: %c"); |
---|
309 | elst[ERR_MODFAIL] = CSAVS(1, 94, "Modifier failed"); |
---|
310 | elst[ERR_SUBOVFL] = CSAVS(1, 95, "Substitution buffer overflow"); |
---|
311 | elst[ERR_BADBANGARG] = CSAVS(1, 96, "Bad ! arg selector"); |
---|
312 | elst[ERR_NOSEARCH] = CSAVS(1, 97, "No prev search"); |
---|
313 | elst[ERR_NOEVENT] = CSAVS(1, 98, "%s: Event not found"); |
---|
314 | elst[ERR_TOOMANYRP] = CSAVS(1, 99, "Too many )'s"); |
---|
315 | elst[ERR_TOOMANYLP] = CSAVS(1, 100, "Too many ('s"); |
---|
316 | elst[ERR_BADPLP] = CSAVS(1, 101, "Badly placed ("); |
---|
317 | elst[ERR_MISRED] = CSAVS(1, 102, "Missing name for redirect"); |
---|
318 | elst[ERR_OUTRED] = CSAVS(1, 103, "Ambiguous output redirect"); |
---|
319 | elst[ERR_REDPAR] = CSAVS(1, 104, "Can't << within ()'s"); |
---|
320 | elst[ERR_INRED] = CSAVS(1, 105, "Ambiguous input redirect"); |
---|
321 | elst[ERR_BADPLPS] = CSAVS(1, 106, "Badly placed ()'s"); |
---|
322 | elst[ERR_ALIASLOOP] = CSAVS(1, 107, "Alias loop"); |
---|
323 | elst[ERR_NOWATCH] = CSAVS(1, 108, "No $watch variable set"); |
---|
324 | elst[ERR_NOSCHED] = CSAVS(1, 109, "No scheduled events"); |
---|
325 | elst[ERR_SCHEDUSAGE] = CSAVS(1, 110, |
---|
326 | "Usage: sched -<item#>.\nUsage: sched [+]hh:mm <command>"); |
---|
327 | elst[ERR_SCHEDEV] = CSAVS(1, 111, "Not that many scheduled events"); |
---|
328 | elst[ERR_SCHEDCOM] = CSAVS(1, 112, "No command to run"); |
---|
329 | elst[ERR_SCHEDTIME] = CSAVS(1, 113, "Invalid time for event"); |
---|
330 | elst[ERR_SCHEDREL] = CSAVS(1, 114, "Relative time inconsistent with am/pm"); |
---|
331 | elst[ERR_TCNOSTR] = CSAVS(1, 115, "Out of termcap string space"); |
---|
332 | elst[ERR_SETTCUS] = CSAVS(1, 116, "Usage: settc %s [yes|no]"); |
---|
333 | elst[ERR_TCCAP] = CSAVS(1, 117, "Unknown capability `%s'"); |
---|
334 | elst[ERR_TCPARM] = CSAVS(1, 118, "Unknown termcap parameter `%%%c'"); |
---|
335 | elst[ERR_TCARGS] = CSAVS(1, 119, "Too many arguments for `%s' (%d)"); |
---|
336 | elst[ERR_TCNARGS] = CSAVS(1, 120, "`%s' requires %d arguments"); |
---|
337 | elst[ERR_TCUSAGE] = CSAVS(1, 121, |
---|
338 | "Usage: echotc [-v|-s] [<capability> [<args>]]"); |
---|
339 | elst[ERR_ARCH] = CSAVS(1, 122, "%s: %s. Binary file not executable"); |
---|
340 | elst[ERR_HISTLOOP] = CSAVS(1, 123, "!# History loop"); |
---|
341 | elst[ERR_FILEINQ] = CSAVS(1, 124, "Malformed file inquiry"); |
---|
342 | elst[ERR_SELOVFL] = CSAVS(1, 125, "Selector overflow"); |
---|
343 | #ifdef apollo |
---|
344 | elst[ERR_TCSHUSAGE] = CSAVS(1, 126, |
---|
345 | "Unknown option: `-%s'\nUsage: %s [ -bcdefilmnqstvVxX -Dname[=value] ] [ argument ... ]"); |
---|
346 | #else /* !apollo */ |
---|
347 | # ifdef convex |
---|
348 | elst[ERR_TCSHUSAGE] = CSAVS(1, 127, |
---|
349 | "Unknown option: `-%s'\nUsage: %s [ -bcdefFilmnqstvVxX ] [ argument ... ]"); |
---|
350 | # else /* rest */ |
---|
351 | elst[ERR_TCSHUSAGE] = CSAVS(1, 128, |
---|
352 | "Unknown option: `-%s'\nUsage: %s [ -bcdefilmnqstvVxX ] [ argument ... ]"); |
---|
353 | # endif /* convex */ |
---|
354 | #endif /* apollo */ |
---|
355 | elst[ERR_COMPCOM] = CSAVS(1, 129, "\nInvalid completion: \"%s\""); |
---|
356 | elst[ERR_COMPINV] = CSAVS(1, 130, "\nInvalid %s: '%c'"); |
---|
357 | elst[ERR_COMPMIS] = CSAVS(1, 131, |
---|
358 | "\nMissing separator '%c' after %s \"%s\""); |
---|
359 | elst[ERR_COMPINC] = CSAVS(1, 132, "\nIncomplete %s: \"%s\""); |
---|
360 | elst[ERR_MFLAG] = CSAVS(1, 133, "No operand for -m flag"); |
---|
361 | elst[ERR_ULIMUS] = CSAVS(1, 134, "Usage: unlimit [-fh] [limits]"); |
---|
362 | elst[ERR_READONLY] = CSAVS(1, 135, "$%S is read-only"); |
---|
363 | elst[ERR_BADJOB] = CSAVS(1, 136, "No such job"); |
---|
364 | elst[ERR_BADCOLORVAR] = CSAVS(1, 137, "Unknown colorls variable `%c%c'"); |
---|
365 | } |
---|
366 | /* |
---|
367 | * The parser and scanner set up errors for later by calling seterr, |
---|
368 | * which sets the variable err as a side effect; later to be tested, |
---|
369 | * e.g. in process. |
---|
370 | */ |
---|
371 | void |
---|
372 | /*VARARGS1*/ |
---|
373 | #ifdef FUNCPROTO |
---|
374 | seterror(unsigned int id, ...) |
---|
375 | #else |
---|
376 | seterror(va_alist) |
---|
377 | va_dcl |
---|
378 | #endif |
---|
379 | { |
---|
380 | |
---|
381 | if (seterr == 0) { |
---|
382 | va_list va; |
---|
383 | char berr[BUFSIZE]; |
---|
384 | #ifdef FUNCPROTO |
---|
385 | va_start(va, id); |
---|
386 | #else |
---|
387 | unsigned int id; |
---|
388 | va_start(va); |
---|
389 | id = va_arg(va, unsigned int); |
---|
390 | #endif |
---|
391 | |
---|
392 | if (id >= sizeof(elst) / sizeof(elst[0])) |
---|
393 | id = ERR_INVALID; |
---|
394 | xvsnprintf(berr, sizeof(berr), elst[id], va); |
---|
395 | va_end(va); |
---|
396 | |
---|
397 | seterr = strsave(berr); |
---|
398 | } |
---|
399 | } |
---|
400 | |
---|
401 | /* |
---|
402 | * Print the error with the given id. |
---|
403 | * |
---|
404 | * Special ids: |
---|
405 | * ERR_SILENT: Print nothing. |
---|
406 | * ERR_OLD: Print the previously set error if one was there. |
---|
407 | * otherwise return. |
---|
408 | * ERR_NAME: If this bit is set, print the name of the function |
---|
409 | * in bname |
---|
410 | * |
---|
411 | * This routine always resets or exits. The flag haderr |
---|
412 | * is set so the routine who catches the unwind can propogate |
---|
413 | * it if they want. |
---|
414 | * |
---|
415 | * Note that any open files at the point of error will eventually |
---|
416 | * be closed in the routine process in sh.c which is the only |
---|
417 | * place error unwinds are ever caught. |
---|
418 | */ |
---|
419 | void |
---|
420 | /*VARARGS*/ |
---|
421 | #ifdef FUNCPROTO |
---|
422 | stderror(unsigned int id, ...) |
---|
423 | #else |
---|
424 | stderror(va_alist) |
---|
425 | va_dcl |
---|
426 | #endif |
---|
427 | { |
---|
428 | va_list va; |
---|
429 | register Char **v; |
---|
430 | int flags; |
---|
431 | int vareturn; |
---|
432 | |
---|
433 | #ifdef FUNCPROTO |
---|
434 | va_start(va, id); |
---|
435 | #else |
---|
436 | unsigned int id; |
---|
437 | |
---|
438 | va_start(va); |
---|
439 | id = va_arg(va, unsigned int); |
---|
440 | #endif |
---|
441 | |
---|
442 | /* |
---|
443 | * Reset don't free flag for buggy os's |
---|
444 | */ |
---|
445 | dont_free = 0; |
---|
446 | |
---|
447 | flags = (int) id & ERR_FLAGS; |
---|
448 | id &= ~ERR_FLAGS; |
---|
449 | |
---|
450 | /* Pyramid's OS/x has a subtle bug in <varargs.h> which prevents calling |
---|
451 | * va_end more than once in the same function. -- sterling@netcom.com |
---|
452 | */ |
---|
453 | if (!((flags & ERR_OLD) && seterr == NULL)) { |
---|
454 | vareturn = 0; /* Don't return immediately after va_end */ |
---|
455 | if (id >= sizeof(elst) / sizeof(elst[0])) |
---|
456 | id = ERR_INVALID; |
---|
457 | |
---|
458 | /* |
---|
459 | * Must flush before we print as we wish output before the error to go |
---|
460 | * on (some form of) standard output, while output after goes on (some |
---|
461 | * form of) diagnostic output. If didfds then output will go to 1/2 |
---|
462 | * else to FSHOUT/FSHDIAG. See flush in sh.print.c. |
---|
463 | */ |
---|
464 | flush(); |
---|
465 | haderr = 1; /* Now to diagnostic output */ |
---|
466 | timflg = 0; /* This isn't otherwise reset */ |
---|
467 | |
---|
468 | |
---|
469 | if (!(flags & ERR_SILENT)) { |
---|
470 | if (flags & ERR_NAME) |
---|
471 | xprintf("%s: ", bname); |
---|
472 | if ((flags & ERR_OLD)) { |
---|
473 | /* Old error. */ |
---|
474 | xprintf("%s.\n", seterr); |
---|
475 | } else { |
---|
476 | xvprintf(elst[id], va); |
---|
477 | xprintf(".\n"); |
---|
478 | } |
---|
479 | } |
---|
480 | } else { |
---|
481 | vareturn = 1; /* Return immediately after va_end */ |
---|
482 | } |
---|
483 | va_end(va); |
---|
484 | if (vareturn) |
---|
485 | return; |
---|
486 | |
---|
487 | if (seterr) { |
---|
488 | xfree((ptr_t) seterr); |
---|
489 | seterr = NULL; |
---|
490 | } |
---|
491 | |
---|
492 | if ((v = pargv) != 0) |
---|
493 | pargv = 0, blkfree(v); |
---|
494 | if ((v = gargv) != 0) |
---|
495 | gargv = 0, blkfree(v); |
---|
496 | |
---|
497 | inheredoc = 0; /* Not anymore in a heredoc */ |
---|
498 | didfds = 0; /* Forget about 0,1,2 */ |
---|
499 | /* |
---|
500 | * Go away if -e or we are a child shell |
---|
501 | */ |
---|
502 | if (exiterr || child) |
---|
503 | xexit(1); |
---|
504 | |
---|
505 | /* |
---|
506 | * Reset the state of the input. This buffered seek to end of file will |
---|
507 | * also clear the while/foreach stack. |
---|
508 | */ |
---|
509 | btoeof(); |
---|
510 | |
---|
511 | set(STRstatus, Strsave(STR1), VAR_READWRITE); |
---|
512 | #ifdef BSDJOBS |
---|
513 | if (tpgrp > 0) |
---|
514 | (void) tcsetpgrp(FSHTTY, tpgrp); |
---|
515 | #endif |
---|
516 | reset(); /* Unwind */ |
---|
517 | } |
---|