From a56608bc3f1ca5be5e3a6155672cf81f14864840 Mon Sep 17 00:00:00 2001 From: Chet Ramey Date: Mon, 21 Sep 2020 08:52:52 -0400 Subject: [PATCH] commit bash-20200914 snapshot --- CWRU/CWRU.chlog | 30 +++++++++++++++++++++++++++++ execute_cmd.c | 7 ++++--- parse.y | 6 +++--- subst.c | 7 ++++++- support/signames.c | 47 +++++++++++++++++++++++++++++++++++++++++++++- syntax.h | 2 +- 6 files changed, 90 insertions(+), 9 deletions(-) diff --git a/CWRU/CWRU.chlog b/CWRU/CWRU.chlog index 7ad0287b..c7f692f1 100644 --- a/CWRU/CWRU.chlog +++ b/CWRU/CWRU.chlog @@ -8999,3 +8999,33 @@ variables.c aclocal.m4 - BASH_STRUCT_WEXITSTATUS_OFFSET: fix typo in loop condition reported by Andreas K. Hüttel + +syntax.h + - slashify_in_here_document: restore previous value that doesn't + include double quote, since it's only special in certain cases + +subst.c + - expand_word_internal: when processing backslash-double quote inside + a ${...} construct inside a here documemt, treat it the same as if + it were double-quoted, as posix says. Fixes report from + Andreas Schwab + + 9/15 + ---- +support/signames.c + - added a number of more esoteric signal names from AIX and Solaris + +parse.y + - report_syntax_error: make sure that the exit status is only set to + one of the special builtin exit statuses if we are really executing + a builtin here, not just if parse_and_execute_level > 0. Reported by + Rob Landley + +execute_cmd.c + - EX_BADSYNTAX: make sure that gets translated into EX_BADUSAGE (2) + - execute_simple_command: if a function returns a value greater than + EX_SHERRBASE, use builtin_status to translate it, as if a builtin + were being executed + - builtin_status: make sure a status > EX_SHERRBASE gets translated to + EXECUTION_FAILURE + diff --git a/execute_cmd.c b/execute_cmd.c index 7cb75f88..f85fe3f3 100644 --- a/execute_cmd.c +++ b/execute_cmd.c @@ -4636,7 +4636,7 @@ run_builtin: if (result == EX_USAGE) result = EX_BADUSAGE; else if (result > EX_SHERRBASE) - result = EXECUTION_FAILURE; + result = builtin_status (result); } set_pipestatus_from_exit (result); @@ -4694,16 +4694,17 @@ builtin_status (result) switch (result) { case EX_USAGE: + case EX_BADSYNTAX: r = EX_BADUSAGE; break; case EX_REDIRFAIL: - case EX_BADSYNTAX: case EX_BADASSIGN: case EX_EXPFAIL: r = EXECUTION_FAILURE; break; default: - r = EXECUTION_SUCCESS; + /* other special exit statuses not yet defined */ + r = (result > EX_SHERRBASE) ? EXECUTION_FAILURE : EXECUTION_SUCCESS; break; } return (r); diff --git a/parse.y b/parse.y index 471669c9..6ab07cd8 100644 --- a/parse.y +++ b/parse.y @@ -6316,7 +6316,7 @@ report_syntax_error (message) parser_error (line_number, "%s", message); if (interactive && EOF_Reached) EOF_Reached = 0; - last_command_exit_value = parse_and_execute_level ? EX_BADSYNTAX : EX_BADUSAGE; + last_command_exit_value = (executing_builtin && parse_and_execute_level) ? EX_BADSYNTAX : EX_BADUSAGE; set_pipestatus_from_exit (last_command_exit_value); return; } @@ -6338,7 +6338,7 @@ report_syntax_error (message) if (interactive == 0) print_offending_line (); - last_command_exit_value = parse_and_execute_level ? EX_BADSYNTAX : EX_BADUSAGE; + last_command_exit_value = (executing_builtin && parse_and_execute_level) ? EX_BADSYNTAX : EX_BADUSAGE; set_pipestatus_from_exit (last_command_exit_value); return; } @@ -6370,7 +6370,7 @@ report_syntax_error (message) EOF_Reached = 0; } - last_command_exit_value = parse_and_execute_level ? EX_BADSYNTAX : EX_BADUSAGE; + last_command_exit_value = (executing_builtin && parse_and_execute_level) ? EX_BADSYNTAX : EX_BADUSAGE; set_pipestatus_from_exit (last_command_exit_value); } diff --git a/subst.c b/subst.c index 300d4eb3..5ffa43ab 100644 --- a/subst.c +++ b/subst.c @@ -10383,7 +10383,12 @@ add_string: c = string[++sindex]; - if (quoted & Q_HERE_DOCUMENT) + /* "However, the double-quote character ( '"' ) shall not be treated + specially within a here-document, except when the double-quote + appears within "$()", "``", or "${}"." */ + if ((quoted & Q_HERE_DOCUMENT) && (quoted & Q_DOLBRACE) && c == '"') + tflag = CBSDQUOTE; /* special case */ + else if (quoted & Q_HERE_DOCUMENT) tflag = CBSHDOC; else if (quoted & Q_DOUBLE_QUOTES) tflag = CBSDQUOTE; diff --git a/support/signames.c b/support/signames.c index d2978089..aba4842a 100644 --- a/support/signames.c +++ b/support/signames.c @@ -1,6 +1,6 @@ /* signames.c -- Create an array of signal names. */ -/* Copyright (C) 2006 Free Software Foundation, Inc. +/* Copyright (C) 2006-2020 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -159,10 +159,18 @@ initialize_signames () signal_names[SIGPRE] = "SIGPRE"; #endif +#if defined (SIGPHONE) /* Phone interrupt */ + signal_names[SIGPHONE] = "SIGPHONE"; +#endif + #if defined (SIGVIRT) /* AIX virtual time alarm */ signal_names[SIGVIRT] = "SIGVIRT"; #endif +#if defined (SIGTINT) /* Interrupt */ + signal_names[SIGTINT] = "SIGTINT"; +#endif + #if defined (SIGALRM1) /* m:n condition variables */ signal_names[SIGALRM1] = "SIGALRM1"; #endif @@ -191,6 +199,18 @@ initialize_signames () signal_names[SIGSAK] = "SIGSAK"; #endif +#if defined (SIGCPUFAIL) /* Predictive processor deconfiguration */ + signal_names[SIGCPUFAIL] = "SIGCPUFAIL"; +#endif + +#if defined (SIGAIO) /* Asynchronous I/O */ + signal_names[SIGAIO] = "SIGAIO"; +#endif + +#if defined (SIGLAB) /* Security label changed */ + signal_names[SIGLAB] = "SIGLAB"; +#endif + /* SunOS5 */ #if defined (SIGLWP) /* Solaris: special signal used by thread library */ signal_names[SIGLWP] = "SIGLWP"; @@ -220,6 +240,31 @@ initialize_signames () signal_names[SIGJVM2] = "SIGJVM2"; #endif +#if defined (SIGDGTIMER1) + signal_names[SIGDGTIMER1] = "SIGDGTIMER1"; +#endif + +#if defined (SIGDGTIMER2) + signal_names[SIGDGTIMER2] = "SIGDGTIMER2"; +#endif + +#if defined (SIGDGTIMER3) + signal_names[SIGDGTIMER3] = "SIGDGTIMER3"; +#endif + +#if defined (SIGDGTIMER4) + signal_names[SIGDGTIMER4] = "SIGDGTIMER4"; +#endif + +#if defined (SIGDGNOTIFY) + signal_names[SIGDGNOTIFY] = "SIGDGNOTIFY"; +#endif + +/* Apollo */ +#if defined (SIGAPOLLO) + signal_names[SIGAPOLLO] = "SIGAPOLLO"; +#endif + /* HP-UX */ #if defined (SIGDIL) /* DIL signal (?) */ signal_names[SIGDIL] = "SIGDIL"; diff --git a/syntax.h b/syntax.h index b808d60d..34f54964 100644 --- a/syntax.h +++ b/syntax.h @@ -24,7 +24,7 @@ /* Defines for use by mksyntax.c */ #define slashify_in_quotes "\\`$\"\n" -#define slashify_in_here_document "\\`$\"" +#define slashify_in_here_document "\\`$" #define shell_meta_chars "()<>;&|" #define shell_break_chars "()<>;&| \t\n"