Bash-5.3-alpha release

This commit is contained in:
Chet Ramey
2024-04-22 10:33:38 -04:00
parent f3b6bd1945
commit 622d318652
700 changed files with 136534 additions and 96420 deletions
+25 -106
View File
@@ -1,6 +1,6 @@
/* error.c -- Functions for handling errors. */
/* Copyright (C) 1993-2021 Free Software Foundation, Inc.
/* Copyright (C) 1993-2022 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -27,12 +27,7 @@
# include <unistd.h>
#endif
#if defined (PREFER_STDARG)
# include <stdarg.h>
#else
# include <varargs.h>
#endif
#include <stdarg.h>
#include <stdio.h>
#include <errno.h>
@@ -52,18 +47,18 @@ extern int errno;
# include "bashhist.h"
#endif
extern int executing_line_number PARAMS((void));
extern int executing_line_number (void);
#if defined (JOB_CONTROL)
extern pid_t shell_pgrp;
extern int give_terminal_to PARAMS((pid_t, int));
extern int give_terminal_to (pid_t, int);
#endif /* JOB_CONTROL */
#if defined (ARRAY_VARS)
extern const char * const bash_badsub_errmsg;
#endif
static void error_prolog PARAMS((int));
static void error_prolog (int);
/* The current maintainer of the shell. You change this in the
Makefile. */
@@ -76,8 +71,7 @@ const char * const the_current_maintainer = MAINTAINER;
int gnu_error_format = 0;
static void
error_prolog (print_lineno)
int print_lineno;
error_prolog (int print_lineno)
{
char *ename;
int line;
@@ -93,7 +87,7 @@ error_prolog (print_lineno)
/* Return the name of the shell or the shell script for error reporting. */
char *
get_name_for_error ()
get_name_for_error (void)
{
char *name;
#if defined (ARRAY_VARS)
@@ -129,20 +123,13 @@ get_name_for_error ()
sys_error so the filename is not interpreted as a printf-style
format string. */
void
file_error (filename)
const char *filename;
file_error (const char *filename)
{
report_error ("%s: %s", filename, strerror (errno));
}
void
#if defined (PREFER_STDARG)
programming_error (const char *format, ...)
#else
programming_error (format, va_alist)
const char *format;
va_dcl
#endif
{
va_list args;
char *h;
@@ -151,7 +138,7 @@ programming_error (format, va_alist)
give_terminal_to (shell_pgrp, 0);
#endif /* JOB_CONTROL */
SH_VA_START (args, format);
va_start (args, format);
vfprintf (stderr, format, args);
fprintf (stderr, "\n");
@@ -180,19 +167,13 @@ programming_error (format, va_alist)
outside this file mostly to report substitution and expansion errors,
and for bad invocation options. */
void
#if defined (PREFER_STDARG)
report_error (const char *format, ...)
#else
report_error (format, va_alist)
const char *format;
va_dcl
#endif
{
va_list args;
error_prolog (1);
SH_VA_START (args, format);
va_start (args, format);
vfprintf (stderr, format, args);
fprintf (stderr, "\n");
@@ -207,19 +188,13 @@ report_error (format, va_alist)
}
void
#if defined (PREFER_STDARG)
fatal_error (const char *format, ...)
#else
fatal_error (format, va_alist)
const char *format;
va_dcl
#endif
{
va_list args;
error_prolog (0);
SH_VA_START (args, format);
va_start (args, format);
vfprintf (stderr, format, args);
fprintf (stderr, "\n");
@@ -229,19 +204,13 @@ fatal_error (format, va_alist)
}
void
#if defined (PREFER_STDARG)
internal_error (const char *format, ...)
#else
internal_error (format, va_alist)
const char *format;
va_dcl
#endif
{
va_list args;
error_prolog (1);
SH_VA_START (args, format);
va_start (args, format);
vfprintf (stderr, format, args);
fprintf (stderr, "\n");
@@ -250,20 +219,14 @@ internal_error (format, va_alist)
}
void
#if defined (PREFER_STDARG)
internal_warning (const char *format, ...)
#else
internal_warning (format, va_alist)
const char *format;
va_dcl
#endif
{
va_list args;
error_prolog (1);
fprintf (stderr, _("warning: "));
SH_VA_START (args, format);
va_start (args, format);
vfprintf (stderr, format, args);
fprintf (stderr, "\n");
@@ -272,13 +235,7 @@ internal_warning (format, va_alist)
}
void
#if defined (PREFER_STDARG)
internal_inform (const char *format, ...)
#else
internal_inform (format, va_alist)
const char *format;
va_dcl
#endif
{
va_list args;
@@ -286,7 +243,7 @@ internal_inform (format, va_alist)
/* TRANSLATORS: this is a prefix for informational messages. */
fprintf (stderr, _("INFORM: "));
SH_VA_START (args, format);
va_start (args, format);
vfprintf (stderr, format, args);
fprintf (stderr, "\n");
@@ -295,13 +252,7 @@ internal_inform (format, va_alist)
}
void
#if defined (PREFER_STDARG)
internal_debug (const char *format, ...)
#else
internal_debug (format, va_alist)
const char *format;
va_dcl
#endif
{
#ifdef DEBUG
va_list args;
@@ -309,7 +260,7 @@ internal_debug (format, va_alist)
error_prolog (1);
fprintf (stderr, _("DEBUG warning: "));
SH_VA_START (args, format);
va_start (args, format);
vfprintf (stderr, format, args);
fprintf (stderr, "\n");
@@ -321,13 +272,7 @@ internal_debug (format, va_alist)
}
void
#if defined (PREFER_STDARG)
sys_error (const char *format, ...)
#else
sys_error (format, va_alist)
const char *format;
va_dcl
#endif
{
int e;
va_list args;
@@ -335,7 +280,7 @@ sys_error (format, va_alist)
e = errno;
error_prolog (0);
SH_VA_START (args, format);
va_start (args, format);
vfprintf (stderr, format, args);
fprintf (stderr, ": %s\n", strerror (e));
@@ -352,14 +297,7 @@ sys_error (format, va_alist)
the input file name is inserted only if it is different from the
shell name. */
void
#if defined (PREFER_STDARG)
parser_error (int lineno, const char *format, ...)
#else
parser_error (lineno, format, va_alist)
int lineno;
const char *format;
va_dcl
#endif
{
va_list args;
char *ename, *iname;
@@ -376,7 +314,7 @@ parser_error (lineno, format, va_alist)
else
fprintf (stderr, "%s: %s:%s%d: ", ename, iname, gnu_error_format ? "" : _(" line "), lineno);
SH_VA_START (args, format);
va_start (args, format);
vfprintf (stderr, format, args);
fprintf (stderr, "\n");
@@ -390,8 +328,7 @@ parser_error (lineno, format, va_alist)
#ifdef DEBUG
/* This assumes ASCII and is suitable only for debugging */
char *
strescape (str)
const char *str;
strescape (const char *str)
{
char *r, *result;
unsigned char *s;
@@ -419,19 +356,13 @@ strescape (str)
}
void
#if defined (PREFER_STDARG)
itrace (const char *format, ...)
#else
itrace (format, va_alist)
const char *format;
va_dcl
#endif
{
va_list args;
fprintf(stderr, "TRACE: pid %ld: ", (long)getpid());
SH_VA_START (args, format);
va_start (args, format);
vfprintf (stderr, format, args);
fprintf (stderr, "\n");
@@ -444,13 +375,7 @@ itrace (format, va_alist)
/* A trace function for silent debugging -- doesn't require a control
terminal. */
void
#if defined (PREFER_STDARG)
trace (const char *format, ...)
#else
trace (format, va_alist)
const char *format;
va_dcl
#endif
{
va_list args;
static FILE *tracefp = (FILE *)NULL;
@@ -465,7 +390,7 @@ trace (format, va_alist)
fprintf(tracefp, "TRACE: pid %ld: ", (long)getpid());
SH_VA_START (args, format);
va_start (args, format);
vfprintf (tracefp, format, args);
fprintf (tracefp, "\n");
@@ -493,9 +418,7 @@ static const char * const cmd_error_table[] = {
};
void
command_error (func, code, e, flags)
const char *func;
int code, e, flags; /* flags currently unused */
command_error (const char *func, int code, int e, int flags)
{
if (code > CMDERR_LAST)
code = CMDERR_DEFAULT;
@@ -504,8 +427,7 @@ command_error (func, code, e, flags)
}
char *
command_errstr (code)
int code;
command_errstr (int code)
{
if (code > CMDERR_LAST)
code = CMDERR_DEFAULT;
@@ -515,23 +437,20 @@ command_errstr (code)
#ifdef ARRAY_VARS
void
err_badarraysub (s)
const char *s;
err_badarraysub (const char *s)
{
report_error ("%s: %s", s, _(bash_badsub_errmsg));
}
#endif
void
err_unboundvar (s)
const char *s;
err_unboundvar (const char *s)
{
report_error (_("%s: unbound variable"), s);
}
void
err_readonly (s)
const char *s;
err_readonly (const char *s)
{
report_error (_("%s: readonly variable"), s);
}