]> git.ipfire.org Git - thirdparty/bash.git/commitdiff
fix for readline numeric args and bind -x commands; fix for printing null simple...
authorChet Ramey <chet.ramey@case.edu>
Wed, 23 Aug 2023 20:32:40 +0000 (16:32 -0400)
committerChet Ramey <chet.ramey@case.edu>
Wed, 23 Aug 2023 20:32:40 +0000 (16:32 -0400)
CWRU/CWRU.chlog
builtins/read.def
execute_cmd.c
lib/readline/misc.c
lib/readline/readline.c
parse.y
print_cmd.c
subst.c

index ab516a2b31b0986c6e06b9581675725347098a5b..5d0480a7ac9035d1f352f3f0d6aa7a61aed634c6 100644 (file)
@@ -7486,3 +7486,34 @@ subst.c
        - parameter_brace_expand_rhs,expand_declaration_argument,
          do_assignment_statements: call posix_variable_assignment_error or
          bash_variable_assignment_error as appropriate
+
+                                  8/21
+                                  ----
+lib/readline/misc.c
+       - _rl_arg_dispatch: add the digits or other characters to
+         rl_executing_keyseq if we're not calling _rl_dispatch.
+         From a report by Grisha Levit <grishalevit@gmail.com>
+
+print_cmd.c
+       - print_simple_command: make sure that the_printed_command[0] == '\0'
+         if we're printing a null simple command with no words
+         Patch by Grisha Levit <grishalevit@gmail.com>
+
+                                  8/22
+                                  ----
+builtins/read.def
+       - read_builtin: make `delim' variable local, pass to edit_line to
+         set the last character of the returned line; change edit_line
+         prototype.
+         From a suggestion by Grisha Levit <grishalevit@gmail.com>
+
+                                  8/23
+                                  ----
+parse.y
+       - comsub and funsub productions: don't reset eof_encountered to 0 in
+         the action
+
+subst.c
+       - function_substitute: unwind-protect eof_encountered so ignoreeof
+         doesn't keep getting reset to 0 if PS1 includes a ${ ...;} command.
+         From a report by Grisha Levit <grishalevit@gmail.com>
index 1c528deb6ddf907b8fff27ab8315bfad9f0b7e7c..8496fe47499dcecc7130556c57605707e00b076b 100644 (file)
@@ -123,7 +123,7 @@ struct ttsave
 #if defined (READLINE)
 static void uw_reset_attempted_completion_function (void *);
 static int set_itext (void);
-static char *edit_line (char *, char *, int);
+static char *edit_line (char *, char *, unsigned char, int);
 static void set_eol_delim (int);
 static void reset_eol_delim (void *);
 static void set_readline_timeout (sh_timer *t, time_t, long);
@@ -144,7 +144,6 @@ static void uw_reset_timeout (void *);
 sh_timer *read_timeout;
 
 static int reading, tty_modified;
-static unsigned char delim;
 
 static struct ttsave termsave;
 
@@ -225,6 +224,7 @@ read_builtin (WORD_LIST *list)
   long ival, uval;
   intmax_t intval;
   char c;
+  unsigned char delim;
   char *input_string, *orig_input_string, *ifs_chars, *prompt, *arrayname;
   char *e, *t, *t1, *ps2, *tofree;
   struct stat tsb;
@@ -251,6 +251,7 @@ read_builtin (WORD_LIST *list)
 /*  USE_VAR(raw); */
   USE_VAR(edit);
   USE_VAR(use_bash_completion);
+  USE_VAR(delim);
   USE_VAR(tmsec);
   USE_VAR(tmusec);
   USE_VAR(nchars);
@@ -660,7 +661,7 @@ read_builtin (WORD_LIST *list)
          if (rlbuf == 0)
            {
              reading = 1;
-             rlbuf = edit_line (prompt ? prompt : "", itext, use_bash_completion);
+             rlbuf = edit_line (prompt ? prompt : "", itext, delim, use_bash_completion);
              reading = 0;
              rlind = 0;
            }
@@ -1208,7 +1209,7 @@ set_itext (void)
 }
 
 static char *
-edit_line (char *p, char *itext, int keep_completion_func)
+edit_line (char *p, char *itext, unsigned char delim, int keep_completion_func)
 {
   char *ret;
   size_t len;
index eaec27680863836b8869fcd3aba080f6289ddf5d..ae5d313c65635210f75ada06c1dd5be6048589d6 100644 (file)
@@ -4401,6 +4401,8 @@ execute_simple_command (SIMPLE_COM *simple_command, int pipe_in, int pipe_out, i
 
   /* Remember what this command line looks like at invocation. */
   command_string_index = 0;
+  if (the_printed_command)
+    the_printed_command[0] = '\0';
   print_simple_command (simple_command);
 
 #if 0
index 7e3efca4ec187cb801b22f2b061de9901887c88c..fdac45d6755b3e34c1a63bc29084282b1e8ca10b 100644 (file)
@@ -150,6 +150,7 @@ _rl_arg_dispatch (_rl_arg_cxt cxt, int c)
 
   if (_rl_digit_p (c))
     {
+      _rl_add_executing_keyseq (key);
       r = _rl_digit_value (c);         
       rl_numeric_arg = rl_explicit_arg ? (rl_numeric_arg * 10) +  r : r;
       rl_explicit_arg = 1;
@@ -157,6 +158,7 @@ _rl_arg_dispatch (_rl_arg_cxt cxt, int c)
     }
   else if (c == '-' && rl_explicit_arg == 0)
     {
+      _rl_add_executing_keyseq (key);
       rl_numeric_arg = 1;
       _rl_argcxt |= NUM_SAWMINUS;
       rl_arg_sign = -1;
index cf70a01dad53f78fdce7a96793e712ce612ba66c..608c65ec3758076aa166652d031b93067e427dc7 100644 (file)
@@ -1576,7 +1576,7 @@ void
 _rl_add_executing_keyseq (int key)
 {
   RESIZE_KEYSEQ_BUFFER ();
- rl_executing_keyseq[rl_key_sequence_length++] = key;
 rl_executing_keyseq[rl_key_sequence_length++] = key;
 }
 
 /* `delete' the last character added to the executing key sequence. Use this
diff --git a/parse.y b/parse.y
index fef0fec5186d5d36731f1106aa0d8075e7b94a2b..8f4240b9a6f95281f61d2f2a3c41797f192e045c 100644 (file)
--- a/parse.y
+++ b/parse.y
@@ -435,7 +435,6 @@ inputunit:  simple_list simple_list_terminator
                          /* This is special; look at the production and how
                             parse_comsub sets token_to_read */
                          global_command = $1;
-                         eof_encountered = 0;
                          YYACCEPT;
                        }
        |       funsub
@@ -443,7 +442,6 @@ inputunit:  simple_list simple_list_terminator
                          /* This is special; look at the production and how
                             parse_comsub/parse_valsub sets token_to_read */
                          global_command = $1;
-                         eof_encountered = 0;
                          YYACCEPT;
                        }
        |       '\n'
index 30e354d3ea111d3259d88eb7116868b13a1159a0..2bf271f453e14e9711e948e4b2064d8565d52513 100644 (file)
@@ -965,6 +965,8 @@ print_simple_command (SIMPLE_COM *simple_command)
 {
   if (simple_command->words)
     command_print_word_list (simple_command->words, " ");
+  else
+    cprintf ("");
 
   if (simple_command->redirects)
     {
diff --git a/subst.c b/subst.c
index 9c14411bb004a14e6df5da080ffbf8b9533b98e7..d8791d1bc24c6405ee5f51f8533a41b6afcff6b0 100644 (file)
--- a/subst.c
+++ b/subst.c
@@ -6921,6 +6921,7 @@ function_substitute (char *string, int quoted, int flags)
   unwind_protect_pointer (subst_assign_varlist);
   unwind_protect_pointer (temporary_env);
   unwind_protect_pointer (this_shell_function);
+  unwind_protect_int (eof_encountered);
   add_unwind_protect (uw_pop_var_context, 0);
 
 #if defined (ARRAY_VARS)