From 68fd3b761506b94c53aab6e66080fbbac8de7699 Mon Sep 17 00:00:00 2001 From: Chet Ramey Date: Mon, 10 Jul 2017 14:57:09 -0400 Subject: [PATCH] commit bash-20170707 snapshot --- CWRU/CWRU.chlog | 33 ++++++++++++++++++++++++++++++++- braces.c | 2 +- builtins/printf.def | 12 ++++++++---- lib/readline/misc.c | 2 ++ lib/readline/signals.c | 2 ++ lib/readline/text.c | 32 +++++++++++++++++++++++++++++--- shell.c | 2 +- 7 files changed, 75 insertions(+), 10 deletions(-) diff --git a/CWRU/CWRU.chlog b/CWRU/CWRU.chlog index a051eb03..f09f0969 100644 --- a/CWRU/CWRU.chlog +++ b/CWRU/CWRU.chlog @@ -1,4 +1,4 @@ -' 2/14/2011 + 2/14/2011 --------- [bash-4.2 released] @@ -14245,3 +14245,34 @@ lib/readline/complete.c - fnprint: make sure print_len is initialized before using it on systems without multibyte character support. Report and fix from Juan Manuel Guerrero + + 7/6 + --- +builtins/printf.def + - PRETURN,printf_builtin: check variable returned by bind_printf_variable, + return failure if that indicates we can't perform an assignment + because the variable is marked readonly or noassign. Fixes bug + reported by Arnaud Gaillard + + 7/7 + --- +lib/readline/text.c + - rl_quoted_insert: new feature: a negative argument means to insert + the next -COUNT characters using quoted-insert. Original feature + from Jason Hood . Still needs work on + redisplay + - _rl_insert_next_callback: implement support for negative arguments + similar to rl_quoted_insert: we just insert one at a time and keep + increasing the count until it hits 0 + +lib/readline/misc.c + - _rl_arg_callback: if the return value from _rl_arg_dispatch indicates + we should keep reading a numeric argument, update the message with + the new arg value + + 7/8 + --- +lib/readline/signals.c + - _rl_handle_signal: make sure all uses of any of the job control + signals are protected by a check for SIGTSTP being defined. Report + from Juan Manuel Guerrero diff --git a/braces.c b/braces.c index 6a5ca5f8..1339b32b 100644 --- a/braces.c +++ b/braces.c @@ -426,7 +426,7 @@ mkseq (start, end, incr, type, width) result = strvec_mcreate (nelem + 1); if (result == 0) { - internal_error (_("brace expansion: failed to allocate memory for %d elements"), nelem); + internal_error (_("brace expansion: failed to allocate memory for %u elements"), (unsigned int)nelem); return ((char **)NULL); } diff --git a/builtins/printf.def b/builtins/printf.def index 5f20e068..3d374ffc 100644 --- a/builtins/printf.def +++ b/builtins/printf.def @@ -1,7 +1,7 @@ This file is printf.def, from which is created printf.c. It implements the builtin "printf" in Bash. -Copyright (C) 1997-2016 Free Software Foundation, Inc. +Copyright (C) 1997-2017 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -148,8 +148,11 @@ extern int errno; QUIT; \ if (vflag) \ { \ - bind_printf_variable (vname, vbuf, 0); \ + SHELL_VAR *v; \ + v = bind_printf_variable (vname, vbuf, 0); \ stupidly_hack_special_variables (vname); \ + if (v == 0 || readonly_p (v) || noassign_p (v)) \ + return (EXECUTION_FAILURE); \ } \ if (conv_bufsize > 4096 ) \ { \ @@ -293,9 +296,10 @@ printf_builtin (list) /* Allow printf -v var "" to act like var="" */ if (vflag && list->word->word && list->word->word[0] == '\0') { - bind_printf_variable (vname, "", 0); + SHELL_VAR *v; + v = bind_printf_variable (vname, "", 0); stupidly_hack_special_variables (vname); - return (EXECUTION_SUCCESS); + return ((v == 0 || readonly_p (v) || noassign_p (v)) ? EXECUTION_FAILURE : EXECUTION_SUCCESS); } if (list->word->word == 0 || list->word->word[0] == '\0') diff --git a/lib/readline/misc.c b/lib/readline/misc.c index 716586c7..64b1457d 100644 --- a/lib/readline/misc.c +++ b/lib/readline/misc.c @@ -275,6 +275,8 @@ _rl_arg_callback (_rl_arg_cxt cxt) } r = _rl_arg_dispatch (cxt, c); + if (r > 0) + rl_message ("(arg: %d) ", rl_arg_sign * rl_numeric_arg); return (r != 1); } diff --git a/lib/readline/signals.c b/lib/readline/signals.c index fcf45b73..add165c5 100644 --- a/lib/readline/signals.c +++ b/lib/readline/signals.c @@ -249,9 +249,11 @@ _rl_handle_signal (int sig) rl_cleanup_after_signal (); #if defined (HAVE_POSIX_SIGNALS) +# if defined (SIGTSTP) /* Unblock SIGTTOU blocked above */ if (sig == SIGTTIN || sig == SIGTSTP) sigprocmask (SIG_UNBLOCK, &set, (sigset_t *)NULL); +# endif sigemptyset (&set); sigprocmask (SIG_BLOCK, (sigset_t *)NULL, &set); diff --git a/lib/readline/text.c b/lib/readline/text.c index 86a13b10..116a33b6 100644 --- a/lib/readline/text.c +++ b/lib/readline/text.c @@ -980,14 +980,29 @@ _rl_insert_next (int count) static int _rl_insert_next_callback (_rl_callback_generic_arg *data) { - int count; + int count, r; count = data->count; + r = 0; + + if (count < 0) + { + data->count++; + r = _rl_insert_next (1); + _rl_want_redisplay = 1; + /* If we should keep going, leave the callback function installed */ + if (data->count < 0 && r == 0) + return r; + count = 0; /* data->count == 0 || r != 0; force break below */ + } /* Deregister function, let rl_callback_read_char deallocate data */ _rl_callback_func = 0; _rl_want_redisplay = 1; - + + if (count == 0) + return r; + return _rl_insert_next (count); } #endif @@ -1009,7 +1024,18 @@ rl_quoted_insert (int count, int key) return (0); } #endif - + + /* A negative count means to quote the next -COUNT characters. */ + if (count < 0) + { + int r; + + do + r = _rl_insert_next (1); + while (r == 0 && ++count < 0); + return r; + } + return _rl_insert_next (count); } diff --git a/shell.c b/shell.c index 3588ed8b..013fece3 100644 --- a/shell.c +++ b/shell.c @@ -578,7 +578,7 @@ main (argc, argv, env) */ if (interactive_shell) { - char *term, *emacs, *inside_emacs;; + char *term, *emacs, *inside_emacs; int emacs_term, in_emacs; term = get_string_value ("TERM");