From: Chet Ramey Date: Wed, 23 Aug 2023 20:32:40 +0000 (-0400) Subject: fix for readline numeric args and bind -x commands; fix for printing null simple... X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=944ac21503250fa02e47f3873573f65bdf53f447;p=thirdparty%2Fbash.git fix for readline numeric args and bind -x commands; fix for printing null simple commands; fix to make read builtin callable recursively; fix for ignoreeof with nofork comsubs in PS1 --- diff --git a/CWRU/CWRU.chlog b/CWRU/CWRU.chlog index ab516a2b3..5d0480a7a 100644 --- a/CWRU/CWRU.chlog +++ b/CWRU/CWRU.chlog @@ -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 + +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 + + 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 + + 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 diff --git a/builtins/read.def b/builtins/read.def index 1c528deb6..8496fe474 100644 --- a/builtins/read.def +++ b/builtins/read.def @@ -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; diff --git a/execute_cmd.c b/execute_cmd.c index eaec27680..ae5d313c6 100644 --- a/execute_cmd.c +++ b/execute_cmd.c @@ -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 diff --git a/lib/readline/misc.c b/lib/readline/misc.c index 7e3efca4e..fdac45d67 100644 --- a/lib/readline/misc.c +++ b/lib/readline/misc.c @@ -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; diff --git a/lib/readline/readline.c b/lib/readline/readline.c index cf70a01da..608c65ec3 100644 --- a/lib/readline/readline.c +++ b/lib/readline/readline.c @@ -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 fef0fec51..8f4240b9a 100644 --- 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' diff --git a/print_cmd.c b/print_cmd.c index 30e354d3e..2bf271f45 100644 --- a/print_cmd.c +++ b/print_cmd.c @@ -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 9c14411bb..d8791d1bc 100644 --- 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)