]> git.ipfire.org Git - thirdparty/bash.git/commitdiff
fix nofork comsub overwriting currently executing command; free readline undo list...
authorChet Ramey <chet.ramey@case.edu>
Fri, 9 Feb 2024 15:30:02 +0000 (10:30 -0500)
committerChet Ramey <chet.ramey@case.edu>
Fri, 9 Feb 2024 15:30:02 +0000 (10:30 -0500)
40 files changed:
CWRU/CWRU.chlog
Makefile.in
arrayfunc.c
bashline.c
braces.c
builtins/cd.def
builtins/hash.def
builtins/printf.def
builtins/set.def
builtins/shopt.def
builtins/ulimit.def
builtins/wait.def
doc/bash.1
doc/bashref.texi
doc/version.texi
execute_cmd.c
execute_cmd.h
externs.h
general.c
jobs.c
jobs.h
lib/readline/callback.c
lib/readline/complete.c
lib/readline/doc/rluser.texi
lib/readline/misc.c
lib/readline/readline.c
lib/readline/readline.h
lib/readline/rlprivate.h
lib/readline/search.c
lib/readline/signals.c
lib/readline/text.c
lib/sh/eaccess.c
lib/sh/tmpfile.c
parse.y
print_cmd.c
redir.c
shell.c
subst.c
test.c
variables.c

index 8c5dc98adbb1213bc278d2b8056c42f04d3b3888..058e667db5230601795cb5faa895f6323fd02e71 100644 (file)
@@ -8503,3 +8503,55 @@ builtins/printf.def
        - PRETURN: clean up vbuf only if vflag is set, and clean it up on
          error (it would get cleaned up on the next call, but...)
          Fixes from Grisha Levit <grishalevit@gmail.com>
+
+                                   2/2
+                                   ---
+doc/bash.1,doc/bashref.texi
+       - word expansions: make it clearer that quote removal is one of the
+         shell word expansions
+
+execute_cmd.c,execute_cmd.h
+       - currently_executing_command: no longer static, so other parts of
+         the shell can save and restore it if necessary
+
+subst.c
+       - function_substitute: unwind-protect currently_executing_command,
+         since parse_and_execute can overwrite it in the current shell
+         execution context.
+         Report from Grisha Levit <grishalevit@gmail.com>
+
+lib/readline/readline.c
+       - readline_common_teardown: new function from the guts of
+         readline_internal_teardown, manages and deallocates rl_undo_list.
+
+lib/readline/callback.c
+       - rl_callback_handler_remove: if we're removing the line handler
+         while we still have an undo list, we didn't call
+         readline_internal_teardown. Call readline_common_teardown to manage
+         the undo list in case we are calling this from a signal handler
+         but not exiting the program.
+         Fixes leaks reported by sparrowhawk996@gmail.com.
+
+variables.c
+       - initialize_shell_variables: use ASS_FORCE when binding SHELLOPTS or
+         BASHOPTS if we get them from the environment, in case they've
+         already been created as shell variables and set to readonly (like
+         changes from 1/30)
+       - set_ppid: use ASS_FORCE in the call to bind_variable instead of
+         temporarily turning off att_readonly
+
+subst.c
+       - extract_delimited_string: pass FLAGS down to skip_single_quoted and
+         skip_double_quoted so we propagate SX_COMMAND and SX_COMPLETE
+         properly.
+         Fixes bug reported by A4-Tacks <wdsjxhno1001@163.com>
+
+                                   2/3
+                                   ---
+bashline.c
+       - initialize_readline: add `bash-vi-complete' as a bindable command
+         name so users can bind other key sequences to it
+       - vi_advance_point: function to advance point by one character even
+         in the presence of multibyte characters 
+       - bash_vi_complete: call vi_advance_point instead of just incrementing
+         rl_point
index b52069e1f41a2a78a33f657141685158f85b67b4..2f863e869eaae8b27aa64f80e8c27558d8e30fa6 100644 (file)
@@ -1,6 +1,6 @@
 # Makefile for bash-5.2, version 5.1
 #
-# Copyright (C) 1996-2021 Free Software Foundation, Inc.
+# Copyright (C) 1996-2024 Free Software Foundation, Inc.
 
 #   This program is free software: you can redistribute it and/or modify
 #   it under the terms of the GNU General Public License as published by
index 57ab0fc378fadc7606d7cd4009664cd273353fb2..d56be4283d90286110085d4d87941344f055edb8 100644 (file)
@@ -1,6 +1,6 @@
 /* arrayfunc.c -- High-level array functions used by other parts of the shell. */
 
-/* Copyright (C) 2001-2023 Free Software Foundation, Inc.
+/* Copyright (C) 2001-2024 Free Software Foundation, Inc.
 
    This file is part of GNU Bash, the Bourne Again SHell.
 
index c11484ecfe4469d37c34aea447e7b8db37a45ae7..c09152c521853fa7b83e56b044a1d51b66006a69 100644 (file)
@@ -1,6 +1,6 @@
 /* bashline.c -- Bash's interface to the readline library. */
 
-/* Copyright (C) 1987-2023 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2024 Free Software Foundation, Inc.
 
    This file is part of GNU Bash, the Bourne Again SHell.
 
@@ -606,6 +606,7 @@ initialize_readline (void)
   rl_bind_key_if_unbound_in_map ('@', posix_edit_macros, vi_movement_keymap);
 #  endif
 
+  rl_add_defun ("bash-vi-complete", bash_vi_complete, -1);
   rl_bind_key_in_map ('\\', bash_vi_complete, vi_movement_keymap);
   rl_bind_key_in_map ('*', bash_vi_complete, vi_movement_keymap);
   rl_bind_key_in_map ('=', bash_vi_complete, vi_movement_keymap);
@@ -4012,10 +4013,38 @@ bash_specific_completion (int what_to_do, rl_compentry_func_t *generator)
 #endif /* SPECIFIC_COMPLETION_FUNCTIONS */
 
 #if defined (VI_MODE)
+/* This does pretty much what _rl_vi_advance_point does. */
+static inline int
+vi_advance_point (void)
+{
+  int point;
+  DECLARE_MBSTATE;
+
+  point = rl_point;
+  if (rl_point < rl_end)
+#if defined (HANDLE_MULTIBYTE)
+    {
+      if (locale_mb_cur_max == 1)
+       rl_point++;
+      else
+       {
+         point = rl_point;
+         ADVANCE_CHAR (rl_line_buffer, rl_end, rl_point);
+         if (point == rl_point || rl_point > rl_end)
+           rl_point = rl_end;
+       }
+    }
+#else
+    rl_point++:
+#endif
+  return point;
+}
+
 /* Completion, from vi mode's point of view.  This is a modified version of
    rl_vi_complete which uses the bash globbing code to implement what POSIX
-   specifies, which is to append a `*' and attempt filename generation (which
-   has the side effect of expanding any globbing characters in the word). */
+   specifies, which is to optinally append a `*' and attempt filename
+   generation (which has the side effect of expanding any globbing characters
+   in the word). */
 static int
 bash_vi_complete (int count, int key)
 {
@@ -4027,7 +4056,7 @@ bash_vi_complete (int count, int key)
     {
       if (!whitespace (rl_line_buffer[rl_point + 1]))
        rl_vi_end_word (1, 'E');
-      rl_point++;
+      vi_advance_point ();
     }
 
   /* Find boundaries of current word, according to vi definition of a
index e2517c9819fba878541bec59a2f5575052182786..17d280734b6b0e66cdab0c067f7738a58a2a5139 100644 (file)
--- a/braces.c
+++ b/braces.c
@@ -1,7 +1,7 @@
 /* braces.c -- code for doing word expansion in curly braces. */
 
-/* Copyright (C) 1987-2020,2022-2023 Free Software Foundation, Inc.
-
+/* Copyright (C) 1987-2020,2022-2024 Free Software Foundation, Inc.
+`
    This file is part of GNU Bash, the Bourne Again SHell.
 
    Bash is free software: you can redistribute it and/or modify
index c8676749ec60e3b033bd51ae805bc9172ec651b9..c99d67cfc0cc3f0cc355f899f814ac982fda91ba 100644 (file)
@@ -1,7 +1,7 @@
 This file is cd.def, from which is created cd.c.  It implements the
 builtins "cd" and "pwd" in Bash.
 
-Copyright (C) 1987-2023 Free Software Foundation, Inc.
+Copyright (C) 1987-2024 Free Software Foundation, Inc.
 
 This file is part of GNU Bash, the Bourne Again SHell.
 
index dd0bf76f4e80231780d67d935867b5e62ffccf93..ee8da9d000b272c1a439fc933efd5b43452543ae 100644 (file)
@@ -1,7 +1,7 @@
 This file is hash.def, from which is created hash.c.
 It implements the builtin "hash" in Bash.
 
-Copyright (C) 1987-2023 Free Software Foundation, Inc.
+Copyright (C) 1987-2024 Free Software Foundation, Inc.
 
 This file is part of GNU Bash, the Bourne Again SHell.
 
index 80d536b44b23f2e70d95ebab7e2d5da0df02e0d0..f7f4de34a7f25130759f8fb27664486991cafe50 100644 (file)
@@ -175,7 +175,7 @@ extern int errno;
       nw = vflag ? vbprintf (f, precision, func) : printf (f, precision, func); \
     else \
       nw = vflag ? vbprintf (f, func) : printf (f, func); \
-    if (nw < 0 || ferror (stdout)) \
+    if (nw < 0 || (vflag == 0 && ferror (stdout))) \
       { \
        QUIT; \
        if (vflag) \
index e0024a973977cafaed71634488df30b789fb97ef..13630c22df706f130183f56a3d7d85b722990135 100644 (file)
@@ -1,7 +1,7 @@
 This file is set.def, from which is created set.c.
 It implements the "set" and "unset" builtins in Bash.
 
-Copyright (C) 1987-2023 Free Software Foundation, Inc.
+Copyright (C) 1987-2024 Free Software Foundation, Inc.
 
 This file is part of GNU Bash, the Bourne Again SHell.
 
index e6c77cc5adbdf7246f43769c9bcc139e51ee4593..b3e1cfe500ca0bec7459246de24bec60ddea4490 100644 (file)
@@ -1,7 +1,7 @@
 This file is shopt.def, from which is created shopt.c.
 It implements the Bash `shopt' builtin.
 
-Copyright (C) 1994-2023 Free Software Foundation, Inc.
+Copyright (C) 1994-2024 Free Software Foundation, Inc.
 
 This file is part of GNU Bash, the Bourne Again SHell.
 
index 64c31e14865d026e58375a4489f53db69ba5457f..1c3ad1fa363087acba9b007b81b2927cfd872ff4 100644 (file)
@@ -1,7 +1,7 @@
 This file is ulimit.def, from which is created ulimit.c.
 It implements the builtin "ulimit" in Bash.
 
-Copyright (C) 1987-2023 Free Software Foundation, Inc.
+Copyright (C) 1987-2024 Free Software Foundation, Inc.
 
 This file is part of GNU Bash, the Bourne Again SHell.
 
index 3f84619787554a6dbe0c0ac2ae2c1b496ddc93d1..a0e43bf828d78674ca76bd99e228a86425b6fef5 100644 (file)
@@ -1,7 +1,7 @@
 This file is wait.def, from which is created wait.c.
 It implements the builtin "wait" in Bash.
 
-Copyright (C) 1987-2023 Free Software Foundation, Inc.
+Copyright (C) 1987-2024 Free Software Foundation, Inc.
 
 This file is part of GNU Bash, the Bourne Again SHell.
 
index bd916b28be25cd610c69d24bc7026d5fef072b64..ff51f89bc3104382920e53d02fae15d3a520b05a 100644 (file)
@@ -5,14 +5,14 @@
 .\"    Case Western Reserve University
 .\"    chet.ramey@case.edu
 .\"
-.\"    Last Change: Thu Jan 18 11:41:18 EST 2024
+.\"    Last Change: Fri Feb  2 09:38:21 EST 2024
 .\"
 .\" bash_builtins, strip all but Built-Ins section
 .\" avoid a warning about an undefined register
 .\" .if !rzY .nr zY 0
 .if \n(zZ=1 .ig zZ
 .if \n(zY=1 .ig zY
-.TH BASH 1 "2024 January 18" "GNU Bash 5.3"
+.TH BASH 1 "2024 February 2" "GNU Bash 5.3"
 .\"
 .\" There's some problem with having a `@'
 .\" in a tagged paragraph with the BSD man macros.
@@ -2978,22 +2978,24 @@ builtins display array values in a way that allows them to be
 reused as assignments.
 .SH EXPANSION
 Expansion is performed on the command line after it has been split into
-words.  There are seven kinds of expansion performed:
+words.  The shell performs these expansions:
 .IR "brace expansion" ,
 .IR "tilde expansion" ,
 .IR "parameter and variable expansion" ,
 .IR "command substitution" ,
 .IR "arithmetic expansion" ,
 .IR "word splitting" ,
+.IR "pathname expansion" ,
 and
-.IR "pathname expansion" .
+.IR "quote removal .
 .PP
 The order of expansions is:
 brace expansion;
 tilde expansion, parameter and variable expansion, arithmetic expansion,
 and command substitution (done in a left-to-right fashion);
 word splitting;
-and pathname expansion.
+pathname expansion;
+and quote removal.
 .PP
 On systems that can support it, there is an additional expansion
 available: \fIprocess substitution\fP.
@@ -3001,9 +3003,10 @@ This is performed at the
 same time as tilde, parameter, variable, and arithmetic expansion and
 command substitution.
 .PP
-After these expansions are performed, quote characters present in the
-original word are removed unless they have been quoted themselves
-(\fIquote removal\fP).
+\fIQuote removal\fP is always performed last.
+It removes quote characters present in the original word,
+not ones resulting from one of the other expansions,
+unless they have been quoted themselves.
 .PP
 Only brace expansion, word splitting, and pathname expansion
 can increase the number of words of the expansion; other expansions
@@ -6825,7 +6828,9 @@ Expand the line by performing shell word expansions.
 This performs alias and history expansion,
 \fB$\fP\(aq\fIstring\fP\(aq and \fB$\fP\(dq\fIstring\fP\(dq quoting,
 tilde expansion, parameter and variable expansion, arithmetic expansion,
+command and process substitution,
 word splitting, and quote removal.
+An explicit argument suppresses command and process substitution.
 See
 .SM
 .B HISTORY EXPANSION
index 41bdcd5ae8e2bf4a434f900b2ea224c3402e07e2..e50494eb2c96b2d4a6b3f243bb1ca4ca7f728420 100644 (file)
@@ -1911,7 +1911,8 @@ to the filename used to invoke Bash, as given by argument zero.
 @cindex expansion
 
 Expansion is performed on the command line after it has been split into
-@code{token}s.  There are seven kinds of expansion performed:
+@code{token}s.
+Bash performs these expansions:
 
 @itemize @bullet
 @item brace expansion
@@ -1921,6 +1922,7 @@ Expansion is performed on the command line after it has been split into
 @item arithmetic expansion
 @item word splitting
 @item filename expansion
+@item quote removal
 @end itemize
 
 @menu
@@ -1943,7 +1945,8 @@ brace expansion;
 tilde expansion, parameter and variable expansion, arithmetic expansion,
 and command substitution (done in a left-to-right fashion);
 word splitting;
-and filename expansion.
+filename expansion;
+and quote removal.
 
 On systems that can support it, there is an additional expansion
 available: @dfn{process substitution}.
@@ -1951,9 +1954,11 @@ This is performed at the
 same time as tilde, parameter, variable, and arithmetic expansion and
 command substitution.
 
-After these expansions are performed, quote characters present in the
-original word are removed unless they have been quoted themselves
-(@dfn{quote removal}). @xref{Quote Removal} for more details.
+@dfn{Quote removal} is always performed last.
+It removes quote characters present in the original word,
+not ones resulting from one of the other expansions,
+unless they have been quoted themselves.
+@xref{Quote Removal} for more details.
 
 Only brace expansion, word splitting, and filename expansion
 can increase the number of words of the expansion; other expansions
@@ -3900,7 +3905,7 @@ If @var{directory} is not supplied, the value of the @env{HOME}
 shell variable is used.
 If the shell variable
 @env{CDPATH} exists, @code{cd} uses it as a search path:
-{cd} searches each directory name in @env{CDPATH} for
+@code{cd} searches each directory name in @env{CDPATH} for
 @var{directory}, with alternative directory names in @env{CDPATH}
 separated by a colon (@samp{:}).
 If @var{directory} begins with a slash, @env{CDPATH} is not used.
index bc3d5d1d4c8d2938a70955416b716d6929f2d796..4e6a512ecf77464486c9b7cca9950a1f02db7b1f 100644 (file)
@@ -2,10 +2,10 @@
 Copyright (C) 1988-2024 Free Software Foundation, Inc.
 @end ignore
 
-@set LASTCHANGE Mon Jan 15 13:13:50 EST 2024
+@set LASTCHANGE Fri Feb  2 09:37:55 EST 2024
 
 @set EDITION 5.3
 @set VERSION 5.3
 
-@set UPDATED 15 January 2024
-@set UPDATED-MONTH January 2024
+@set UPDATED 2 February 2024
+@set UPDATED-MONTH February 2024
index f13114b934b73a8dd3c6122c2348ac8a6ab2d8b9..0a5e330512c0820cddf8eaaac5e26b9711d1bbaf 100644 (file)
@@ -1,6 +1,6 @@
 /* execute_cmd.c -- Execute a COMMAND structure. */
 
-/* Copyright (C) 1987-2023 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2024 Free Software Foundation, Inc.
 
    This file is part of GNU Bash, the Bourne Again SHell.
 
@@ -207,6 +207,9 @@ char *this_command_name;
    a debugger to know where exactly the program is currently executing. */
 char *the_printed_command_except_trap;
 
+/* Used to compute the correct line number. */
+COMMAND *currently_executing_command;
+
 /* For catching RETURN in a function. */
 int return_catch_flag;
 int return_catch_value;
@@ -267,8 +270,6 @@ struct stat SB;             /* used for debugging */
 
 static int special_builtin_failed;
 
-static COMMAND *currently_executing_command;
-
 /* The line number that the currently executing function starts on. */
 static int function_line_number;
 
index 44c60ba8adcbe1b10b9fa384cfa9f0bf9fd5ebc4..f55409999a389546707eb1d31c03142d27c921b7 100644 (file)
@@ -63,6 +63,7 @@ extern int stdin_redir;
 extern int line_number_for_err_trap;
 
 extern char *the_printed_command_except_trap;
+extern COMMAND *currently_executing_command;
 
 extern char *this_command_name;
 extern SHELL_VAR *this_shell_function;
index 6bd1366416df2ead242e2cae83248f09966ccf79..6376bf41e67af5ac07c866e20c9982733556d853 100644 (file)
--- a/externs.h
+++ b/externs.h
@@ -1,7 +1,7 @@
 /* externs.h -- extern function declarations which do not appear in their
    own header file. */
 
-/* Copyright (C) 1993-2023 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2024 Free Software Foundation, Inc.
 
    This file is part of GNU Bash, the Bourne Again SHell.
 
index 63600999790f7982f0bff6b7376ada6532d6f6f8..94082fdf884e96e9504da61c81e0f35cd5b5228d 100644 (file)
--- a/general.c
+++ b/general.c
@@ -1,6 +1,6 @@
 /* general.c -- Stuff that is used by all files. */
 
-/* Copyright (C) 1987-2023 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2024 Free Software Foundation, Inc.
 
    This file is part of GNU Bash, the Bourne Again SHell.
 
diff --git a/jobs.c b/jobs.c
index f9fc82376475661124f6462b0f153222fd20b044..c0569c2e148cdd5c4701f1dddb1cf8644a11cfbe 100644 (file)
--- a/jobs.c
+++ b/jobs.c
@@ -3,7 +3,7 @@
 /* This file works with both POSIX and BSD systems.  It implements job
    control. */
 
-/* Copyright (C) 1989-2023 Free Software Foundation, Inc.
+/* Copyright (C) 1989-2024 Free Software Foundation, Inc.
 
    This file is part of GNU Bash, the Bourne Again SHell.
 
diff --git a/jobs.h b/jobs.h
index ff6677a09a5e21c0cc4ac6b8d32d71e0f75e8b00..7ac7b22bdab532db5d739f8db557f45a0803ec73 100644 (file)
--- a/jobs.h
+++ b/jobs.h
@@ -1,6 +1,6 @@
 /* jobs.h -- structures and definitions used by the jobs.c file. */
 
-/* Copyright (C) 1993-2023 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2024 Free Software Foundation, Inc.
 
    This file is part of GNU Bash, the Bourne Again SHell.
 
index d376f948f60d9d80cd9b5332b7cf5f5c0ec525f9..180b683f9098a973646fb39de5e9dfc135d79f29 100644 (file)
@@ -1,6 +1,6 @@
 /* callback.c -- functions to use readline as an X `callback' mechanism. */
 
-/* Copyright (C) 1987-2022 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2024 Free Software Foundation, Inc.
 
    This file is part of the GNU Readline Library (Readline), a library
    for reading lines of text with interactive input and history editing.
@@ -323,6 +323,15 @@ rl_callback_handler_remove (void)
   rl_linefunc = NULL;
   RL_UNSETSTATE (RL_STATE_CALLBACK);
   RL_CHECK_SIGNALS ();
+
+  /* Do what we need to do to manage the undo list if we haven't already done
+     it in rl_callback_read_char(). If there's no undo list, we don't need to
+     do anything. It doesn't matter if we try to revert all previous lines a
+     second time; none of the history entries will have an undo list. */
+  if (rl_undo_list)
+    readline_common_teardown ();
+  /* At this point, rl_undo_list == NULL. */
+
   if (in_handler)
     {
       in_handler = 0;
index d0165cc733fd539ed0444c820ccd1d77b7baf642..f564a47f54d12e171366dabc069a95a5dc5dc805 100644 (file)
@@ -1,6 +1,6 @@
 /* complete.c -- filename completion for readline. */
 
-/* Copyright (C) 1987-2022,2023 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2024 Free Software Foundation, Inc.
 
    This file is part of the GNU Readline Library (Readline), a library
    for reading lines of text with interactive input and history editing.
index aa64852e993f9bb202058f5f78086784dd3442fc..1e3823cf2ebde55e56fedc6426076dd23593eee0 100644 (file)
@@ -1,5 +1,7 @@
 @comment %**start of header (This is for running Texinfo on a region.)
+@ifclear BashFeatures
 @setfilename rluser.info
+@end ifclear
 @comment %**end of header (This is for running Texinfo on a region.)
 
 @ignore
@@ -1874,8 +1876,10 @@ Display version information about the current instance of Bash.
 Expand the line by performing shell word expansions.  
 This performs alias and history expansion,
 $'@var{string}' and $"@var{string}" quoting,
-tilde expansion, parameter and variable expansion, arithmetic expansion,  
+tilde expansion, parameter and variable expansion, arithmetic expansion,
+command and proces substitution,
 word splitting, and quote removal.  
+An explicit argument suppresses command and process substitution.
 
 @item history-expand-line (M-^)
 Perform history expansion on the current line.
index bbb0332a5c0f374dc42edffdb8b97c96e293cecb..96c82b54d1bae8e8d33adced07af230ef9b4bcdb 100644 (file)
@@ -1,6 +1,6 @@
 /* misc.c -- miscellaneous bindable readline functions. */
 
-/* Copyright (C) 1987-2023 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2024 Free Software Foundation, Inc.
 
    This file is part of the GNU Readline Library (Readline), a library
    for reading lines of text with interactive input and history editing.      
index 696eee80054760853eab190459765e72bd8c0e3e..979090979f1c207a028197362a2ad5b9f7c8115e 100644 (file)
@@ -474,17 +474,12 @@ readline_internal_setup (void)
   RL_CHECK_SIGNALS ();
 }
 
-STATIC_CALLBACK char *
-readline_internal_teardown (int eof)
+STATIC_CALLBACK void
+readline_common_teardown (void)
 {
   char *temp;
   HIST_ENTRY *entry;
 
-  RL_CHECK_SIGNALS ();
-
-  if (eof)
-    RL_SETSTATE (RL_STATE_EOF);                /* XXX */
-
   /* Restore the original of this history line, iff the line that we
      are editing was originally in the history, AND the line has changed. */
   entry = current_history ();
@@ -510,6 +505,17 @@ readline_internal_teardown (int eof)
      rid of it now. */
   if (rl_undo_list)
     rl_free_undo_list ();
+}
+       
+STATIC_CALLBACK char *
+readline_internal_teardown (int eof)
+{
+  RL_CHECK_SIGNALS ();
+
+  if (eof)
+    RL_SETSTATE (RL_STATE_EOF);                /* XXX */
+
+  readline_common_teardown ();
 
   /* Disable the meta key, if this terminal has one and we were told to use it.
      The check whether or not we sent the enable string is in
index 3224706f72bf7a626f789e03096f07ee1b315fe2..22b9ca9b6f633ac1932950c4cc2abe44531fe395 100644 (file)
@@ -1,6 +1,6 @@
 /* Readline.h -- the names of functions callable from within readline. */
 
-/* Copyright (C) 1987-2023 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2024 Free Software Foundation, Inc.
 
    This file is part of the GNU Readline Library (Readline), a library
    for reading lines of text with interactive input and history editing.      
index a2ab98bc1487c77777f7ee75f73c79fc2bc281db..61d04a459f84dc06ed249598aa2606284a02cd20 100644 (file)
@@ -1,7 +1,7 @@
 /* rlprivate.h -- functions and variables global to the readline library,
                  but not intended for use by applications. */
 
-/* Copyright (C) 1999-2023 Free Software Foundation, Inc.
+/* Copyright (C) 1999-2024 Free Software Foundation, Inc.
 
    This file is part of the GNU Readline Library (Readline), a library
    for reading lines of text with interactive input and history editing.
@@ -270,10 +270,11 @@ extern char *_rl_savestring (const char *);
  * Undocumented private functions                                       *
  *************************************************************************/
 
-#if defined(READLINE_CALLBACKS)
+#if defined (READLINE_CALLBACKS)
 
 /* readline.c */
 extern void readline_internal_setup (void);
+extern void readline_common_teardown (void);
 extern char *readline_internal_teardown (int);
 extern int readline_internal_char (void);
 
index 6b078d7c243a2601e10f9ed61fb6631add6ceaff..a22c43d4fc6e925c38a96ec23b91f38492302c13 100644 (file)
@@ -1,6 +1,6 @@
 /* search.c - code for non-incremental searching in emacs and vi modes. */
 
-/* Copyright (C) 1992-2023 Free Software Foundation, Inc.
+/* Copyright (C) 1992-2024 Free Software Foundation, Inc.
 
    This file is part of the GNU Readline Library (Readline), a library
    for reading lines of text with interactive input and history editing.      
index 92dd2ffc94a4904dbc559d83e36dee1f1df9f07d..706035e9f415cbafee90512979bdad8959735571 100644 (file)
@@ -1,6 +1,6 @@
 /* signals.c -- signal handling support for readline. */
 
-/* Copyright (C) 1987-2021 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2024 Free Software Foundation, Inc.
 
    This file is part of the GNU Readline Library (Readline), a library
    for reading lines of text with interactive input and history editing.      
index 26ded8f3ba1913276c649e60b18f699d88d78df5..c5281efe14f88cc31a412a2ab1f874a465c09442 100644 (file)
@@ -1,6 +1,6 @@
 /* text.c -- text handling commands for readline. */
 
-/* Copyright (C) 1987-2021,2023 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2021,2023-2024 Free Software Foundation, Inc.
 
    This file is part of the GNU Readline Library (Readline), a library
    for reading lines of text with interactive input and history editing.      
index abeead2d66797b4201f270f6dc0ccb8bca03dccf..0d2c44b5c23b998075546e11d18afb0957665903 100644 (file)
@@ -1,6 +1,6 @@
 /* eaccess.c - eaccess replacement for the shell, plus other access functions. */
 
-/* Copyright (C) 2006-2020,2022-2023 Free Software Foundation, Inc.
+/* Copyright (C) 2006-2020,2022-2024 Free Software Foundation, Inc.
 
    This file is part of GNU Bash, the Bourne Again SHell.
 
index 650c0ac0e80cedeb705681262016ead335619b2d..006b6b177e2081624247b8010b3b4c166b836a9b 100644 (file)
@@ -2,7 +2,7 @@
  * tmpfile.c - functions to create and safely open temp files for the shell.
  */
 
-/* Copyright (C) 2000-2020,2022-2023 Free Software Foundation, Inc.
+/* Copyright (C) 2000-2020,2022-2024 Free Software Foundation, Inc.
 
    This file is part of GNU Bash, the Bourne Again SHell.
 
diff --git a/parse.y b/parse.y
index 15e52dbc9446299d0c19a392113db0896cb23c25..551e03d0ddd6dcdb1d95f85111277bd51776e172 100644 (file)
--- a/parse.y
+++ b/parse.y
@@ -1,6 +1,6 @@
 /* parse.y - Yacc grammar for bash. */
 
-/* Copyright (C) 1989-2023 Free Software Foundation, Inc.
+/* Copyright (C) 1989-2024 Free Software Foundation, Inc.
 
    This file is part of GNU Bash, the Bourne Again SHell.
 
index 0886b5c2c9bbd5977bc43acd54a0fbf9003b2ff7..330223d3833c1f34e799020bd53fc034b6758277 100644 (file)
@@ -1,6 +1,6 @@
 /* print_command -- A way to make readable commands from a command tree. */
 
-/* Copyright (C) 1989-2023 Free Software Foundation, Inc.
+/* Copyright (C) 1989-2024 Free Software Foundation, Inc.
 
    This file is part of GNU Bash, the Bourne Again SHell.
 
diff --git a/redir.c b/redir.c
index 65ddf20169ebea7dbf9ad678c0f4b61ed52d1995..6c2f62d2eb3c43d4fc236c252cd2ad5f448d1514 100644 (file)
--- a/redir.c
+++ b/redir.c
@@ -1,6 +1,6 @@
 /* redir.c -- Functions to perform input and output redirection. */
 
-/* Copyright (C) 1997-2023 Free Software Foundation, Inc.
+/* Copyright (C) 1997-2024 Free Software Foundation, Inc.
 
    This file is part of GNU Bash, the Bourne Again SHell.
 
diff --git a/shell.c b/shell.c
index 7fb300ac014877ec606777ccb6a24289630a8f22..add8b1cd3ef7efc5deda09536f920357fe6b11f8 100644 (file)
--- a/shell.c
+++ b/shell.c
@@ -1,6 +1,6 @@
 /* shell.c -- GNU's idea of the POSIX shell specification. */
 
-/* Copyright (C) 1987-2023 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2024 Free Software Foundation, Inc.
 
    This file is part of GNU Bash, the Bourne Again SHell.
 
diff --git a/subst.c b/subst.c
index 331e2995d5f34519070dc605e48010094f374d1e..ed7da9d2a5d24cafd1fb57ecbd7f3335d67d6503 100644 (file)
--- a/subst.c
+++ b/subst.c
@@ -4,7 +4,7 @@
 /* ``Have a little faith, there's magic in the night.  You ain't a
      beauty, but, hey, you're alright.'' */
 
-/* Copyright (C) 1987-2023 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2024 Free Software Foundation, Inc.
 
    This file is part of GNU Bash, the Bourne Again SHell.
 
@@ -1299,15 +1299,20 @@ extract_arithmetic_subst (const char *string, size_t *sindex)
 char *
 extract_process_subst (const char *string, char *starter, size_t *sindex, int xflags)
 {
+  char *ret;
+  char *xstr;
 #if 0
   /* XXX - check xflags&SX_COMPLETE here? */
-  return (extract_delimited_string (string, sindex, starter, "(", ")", SX_COMMAND));
+  if (flags & SX_COMPLETE)
+    return (extract_delimited_string (string, sindex, starter, "(", ")", SX_COMMAND));
+  else
 #else
-  char *xstr;
-
-  xflags |= (no_longjmp_on_fatal_error ? SX_NOLONGJMP : 0);
-  xstr = (char *)string + *sindex;
-  return (xparse_dolparen (string, xstr, sindex, xflags));
+    {
+      xflags |= (no_longjmp_on_fatal_error ? SX_NOLONGJMP : 0);
+      xstr = (char *)string + *sindex;
+      ret = xparse_dolparen (string, xstr, sindex, xflags);
+      return ret;
+    }
 #endif
 }
 #endif /* PROCESS_SUBSTITUTION */
@@ -1344,7 +1349,7 @@ extract_array_assignment_list (const char *string, size_t *sindex)
 static char *
 extract_delimited_string (const char *string, size_t *sindex, char *opener, char *alt_opener, char *closer, int flags)
 {
-  int c;
+  int c, xflags;
   size_t i, si, slen;
   char *t, *result;
   int pass_character, nesting_level, in_comment;
@@ -1472,8 +1477,8 @@ extract_delimited_string (const char *string, size_t *sindex, char *opener, char
       if (c == '\'' || c == '"')
        {
          si = i + 1;
-         i = (c == '\'') ? skip_single_quoted (string, slen, si, 0)
-                         : skip_double_quoted (string, slen, si, 0);
+         i = (c == '\'') ? skip_single_quoted (string, slen, si, flags)
+                         : skip_double_quoted (string, slen, si, flags);
          continue;
        }
 
@@ -6917,6 +6922,7 @@ function_substitute (char *string, int quoted, int flags)
   unwind_protect_pointer (this_shell_function);
   unwind_protect_pointer (this_shell_builtin);
   unwind_protect_pointer (current_builtin);
+  unwind_protect_pointer (currently_executing_command);
   unwind_protect_int (eof_encountered);
   add_unwind_protect (uw_pop_var_context, 0);
   add_unwind_protect (uw_maybe_restore_getopt_state, gs);
@@ -6992,6 +6998,7 @@ function_substitute (char *string, int quoted, int flags)
 
   remove_quoted_escapes (string);
 
+  currently_executing_command = NULL;
   executing_funsub++;
   if (expand_aliases)
     expand_aliases = posixly_correct == 0;
diff --git a/test.c b/test.c
index 3d1a5693cc9770c5ade017a99e4e2f42f8addd65..6967ef95d9814bb309e451f5f550705d50727ddf 100644 (file)
--- a/test.c
+++ b/test.c
@@ -2,7 +2,7 @@
 
 /* Modified to run with the GNU shell Apr 25, 1988 by bfox. */
 
-/* Copyright (C) 1987-2023 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2024 Free Software Foundation, Inc.
 
    This file is part of GNU Bash, the Bourne Again SHell.
 
index e54bd14bd33e30c9922df7c362584796f5e304a0..85bdf39aa72e2b45f5b0f2338d523f1545390ced 100644 (file)
@@ -503,25 +503,18 @@ initialize_shell_variables (char **env, int privmode)
 #  endif /* ARRAY_EXPORT */
 #endif
        {
-         ro = 0;
-         /* If we processed a command-line option that caused SHELLOPTS to be
-            set, it may already be set (and read-only) by the time we process
-            the shell's environment. */
-         if (/* posixly_correct &&*/ STREQ (name, "SHELLOPTS"))
-           {
-             temp_var = find_variable ("SHELLOPTS");
-             ro = temp_var && readonly_p (temp_var);
-             if (temp_var)
-               VUNSETATTR (temp_var, att_readonly);
-           }
+         /* If we processed a command-line option that caused SHELLOPTS or
+            BASHOPTS to be set, it may already be set (and read-only) by the
+            time we process the shell's environment. */
+         ro = STREQ (name, "SHELLOPTS") || STREQ (name, "BASHOPTS");
          if (valid_identifier (name))
            {
-             temp_var = bind_variable (name, string, 0);
+             temp_var = bind_variable (name, string, ro ? ASS_FORCE : 0);
              if (temp_var)
                {
                  VSETATTR (temp_var, (att_exported | att_imported));
                  if (ro)
-                   VSETATTR (temp_var, att_readonly);
+                   VSETATTR (temp_var, att_readonly);  /* just make sure */
                }
            }
          else
@@ -981,8 +974,8 @@ set_ppid (void)
   name = inttostr (getppid (), namebuf, sizeof(namebuf));
   temp_var = find_variable ("PPID");
   if (temp_var)
-    VUNSETATTR (temp_var, (att_readonly | att_exported));
-  temp_var = bind_variable ("PPID", name, 0);
+    VUNSETATTR (temp_var, att_exported);
+  temp_var = bind_variable ("PPID", name, ASS_FORCE);
   VSETATTR (temp_var, (att_readonly | att_integer));
 }