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

This commit is contained in:
Chet Ramey
2023-08-23 16:32:40 -04:00
parent b64a7d8cbe
commit 944ac21503
8 changed files with 44 additions and 7 deletions
+31
View 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>
+5 -4
View 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;
+2
View 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
+2
View 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;
+1 -1
View 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
-2
View File
@@ -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'
+2
View 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)
{
+1
View File
@@ -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)