/* Used by built-in utilities to prefix shell and utility name to message * (also unwinds environments for special builtins). */ void bi_errorf(const char *fmt, ...) { va_list va; shl_stdout_ok = 0; /* debugging: note that stdout not valid */ exstat = 1; if (fmt != NULL && *fmt != '\0') { error_prefix(true); /* not set when main() calls parse_args() */ if (builtin_argv0) shf_fprintf(shl_out, "%s: ", builtin_argv0); va_start(va, fmt); shf_vfprintf(shl_out, fmt, va); va_end(va); shf_putchar('\n', shl_out); } shf_flush(shl_out); /* POSIX special builtins and ksh special builtins cause * non-interactive shells to exit. * XXX odd use of KEEPASN; also may not want LERROR here */ if ((builtin_flag & SPEC_BI) || (Flag(FPOSIX) && (builtin_flag & KEEPASN))) { builtin_argv0 = NULL; unwind(LERROR); } }
/* like errorf(), but no unwind is done */ void warningf(bool show_lineno, const char *fmt, ...) { va_list va; error_prefix(show_lineno); va_start(va, fmt); shf_vfprintf(shl_out, fmt, va); va_end(va); shf_putchar('\n', shl_out); shf_flush(shl_out); }
/* Called when something that shouldn't happen does */ void internal_errorf(int jump, const char *fmt, ...) { va_list va; error_prefix(true); shf_fprintf(shl_out, "internal error: "); va_start(va, fmt); shf_vfprintf(shl_out, fmt, va); va_end(va); shf_putchar('\n', shl_out); shf_flush(shl_out); if (jump) unwind(LERROR); }
void yyerror(const char *fmt, ...) { va_list va; /* pop aliases and re-reads */ while (source->type == SALIAS || source->type == SREREAD) source = source->next; source->str = null; /* zap pending input */ error_prefix(true); va_start(va, fmt); shf_vfprintf(shl_out, fmt, va); va_end(va); errorf(null); }
/* A shell error occurred (eg, syntax error, etc.) */ void errorf(const char *fmt, ...) { va_list va; shl_stdout_ok = 0; /* debugging: note that stdout not valid */ exstat = 1; if (fmt != NULL && *fmt != '\0') { error_prefix(true); va_start(va, fmt); shf_vfprintf(shl_out, fmt, va); va_end(va); shf_putchar('\n', shl_out); } shf_flush(shl_out); unwind(LERROR); }
static void vwarningf(unsigned int flags, const char *fmt, va_list ap) { if (fmt) { if (flags & VWARNINGF_INTERNAL) shf_fprintf(shl_out, Tf_sD_, "internal error"); if (flags & VWARNINGF_ERRORPREFIX) error_prefix(tobool(flags & VWARNINGF_FILELINE)); if ((flags & VWARNINGF_BUILTIN) && /* not set when main() calls parse_args() */ builtin_argv0 && builtin_argv0 != kshname) shf_fprintf(shl_out, Tf_sD_, builtin_argv0); shf_vfprintf(shl_out, fmt, ap); shf_putchar('\n', shl_out); } shf_flush(shl_out); }