* Copyright (c) 1980 Regents of the University of California.
* All rights reserved. The Berkeley Software License Agreement
* specifies the terms and conditions for redistribution.
static char *sccsid
= "@(#)err.c 5.3 (Berkeley) %G%";
bool errspl
; /* Argument to error was spliced by seterr2 */
char one
[2] = { '1', 0 };
char *onev
[2] = { one
, NOSTR
};
* Print error string s with optional argument arg.
* This routine always resets or exits. The flag haderr
* is set so the routine who catches the unwind can propogate
* Note that any open files at the point of error will eventually
* be closed in the routine process in sh.c which is the only
* place error unwinds are ever caught.
* Must flush before we print as we wish output before the error
* to go on (some form of) standard output, while output after
* goes on (some form of) diagnostic output.
* If didfds then output will go to 1/2 else to FSHOUT/FSHDIAG.
* See flush in sh.print.c.
haderr
= 1; /* Now to diagnostic output */
timflg
= 0; /* This isn't otherwise reset */
* A zero arguments causes no printing, else print
* an error diagnostic here.
printf(s
, arg
), printf(".\n");
didfds
= 0; /* Forget about 0,1,2 */
if ((ep
= err
) && errspl
) {
* Go away if -e or we are a child shell
* Reset the state of the input.
* This buffered seek to end of file will also
* clear the while/foreach stack.
setq("status", onev
, &shvhed
);
(void) ioctl(FSHTTY
, TIOCSPGRP
, (char *)&tpgrp
);
* Perror is the shells version of perror which should otherwise
* Perror uses unit 2, thus if we didn't set up the fd's
* we must set up unit 2 now else the diagnostic will disappear
register int oerrno
= errno
;
error(NOSTR
); /* To exit or unwind */
* The parser and scanner set up errors for later by calling seterr,
* which sets the variable err as a side effect; later to be tested,
/* Set err to a splice of cp and dp, to be freed later in error() */
/* Set err to a splice of cp with a string form of character d */