From f6388ab9138a6e0cda398b19c4e4989fcd680283 Mon Sep 17 00:00:00 2001 From: Chet Ramey Date: Thu, 7 Mar 2019 12:08:22 -0500 Subject: [PATCH] commit bash-20190306 snapshot --- CWRU/CWRU.chlog | 28 +++++++++++++ MANIFEST | 1 + lib/readline/doc/rltech.texi | 13 +++--- lib/readline/doc/version.texi | 8 ++-- subst.c | 28 +++++++++---- tests/dollar-at-star | 4 ++ tests/dollar-star10.sub | 79 +++++++++++++++++++++++++++++++++++ 7 files changed, 145 insertions(+), 16 deletions(-) create mode 100644 tests/dollar-star10.sub diff --git a/CWRU/CWRU.chlog b/CWRU/CWRU.chlog index 57f1c618..cefc5ec4 100644 --- a/CWRU/CWRU.chlog +++ b/CWRU/CWRU.chlog @@ -5431,3 +5431,31 @@ examples/loadables/fdflags.c execute_cmd.c - execute_connection: call optimize_fork on the rhs of a `;' connection to attempt to optimize the last simple command in a list + + 3/4 + --- +subst.c + - parameter_brace_expand: add `@' to the list of operators that cause + unbound parameter errors. Fixes oversight bug reported by + Martin Schulte + + 3/5 + --- +subst.c + - expand_word_internal: update to fix from 2/21 and 2/27 to accommodate + contexts when word splitting will not take place (W_ASSIGNRHS). Fix + from Grisha Levit + - param_expand: if IFS is unset, and we are expanding $* in a context + where we're not going to be performing word splitting, just treat it + as if IFS=" " and don't set W_SPLITSPACE. Report and hint at fix + from Grisha Levit + - param_expand: if IFS is not null, and we are expanding $* in a + context where we're not going to be performing word splitting, and + we quote a null string (resulting in a quoted null), make sure we + set W_SAWQUOTEDNULL to note this for the caller + - parameter_brace_expand_rhs: make sure to remove any W_SAWQUOTEDNULL + flag for a the word on the rhs of the `=' operator if the original + string is null or the original string is not null and the returned + string (after dequoting) is not null. For instance ${v= ''} should + not have the SAWQUOTEDNULL flag set because it is " " after + expansion and dequoting, even though we saw a quoted null there diff --git a/MANIFEST b/MANIFEST index afba5cea..dff68247 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1009,6 +1009,7 @@ tests/dollar-star6.sub f tests/dollar-star7.sub f tests/dollar-star8.sub f tests/dollar-star9.sub f +tests/dollar-star10.sub f tests/dollar.right f tests/dstack.tests f tests/dstack.right f diff --git a/lib/readline/doc/rltech.texi b/lib/readline/doc/rltech.texi index 28a02d99..15231392 100644 --- a/lib/readline/doc/rltech.texi +++ b/lib/readline/doc/rltech.texi @@ -7,7 +7,7 @@ This document describes the GNU Readline Library, a utility for aiding in the consistency of user interface across discrete programs that need to provide a command line interface. -Copyright (C) 1988--2016 Free Software Foundation, Inc. +Copyright (C) 1988--2019 Free Software Foundation, Inc. Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice @@ -1733,8 +1733,8 @@ to determine whether or not there are any pending signals. If an application does not wish Readline to catch @code{SIGWINCH}, it may call @code{rl_resize_terminal()} or @code{rl_set_screen_size()} to force -Readline to update its idea of the terminal size when a @code{SIGWINCH} -is received. +Readline to update its idea of the terminal size when it receives +a @code{SIGWINCH}. @deftypefun void rl_echo_signal_char (int sig) If an application wishes to install its own signal handlers, but still @@ -1751,11 +1751,14 @@ Update Readline's internal screen size by reading values from the kernel. Set Readline's idea of the terminal size to @var{rows} rows and @var{cols} columns. If either @var{rows} or @var{columns} is less than or equal to 0, Readline's idea of that terminal dimension is unchanged. +This is intended to tell Readline the physical dimensions of the terminal, +and is used internally to calculate the maximum number of characters that +may appear on the screen. @end deftypefun If an application does not want to install a @code{SIGWINCH} handler, but -is still interested in the screen dimensions, Readline's idea of the screen -size may be queried. +is still interested in the screen dimensions, it may query Readline's idea +of the screen size. @deftypefun void rl_get_screen_size (int *rows, int *cols) Return Readline's idea of the terminal's size in the diff --git a/lib/readline/doc/version.texi b/lib/readline/doc/version.texi index 576c35c8..f9c774ce 100644 --- a/lib/readline/doc/version.texi +++ b/lib/readline/doc/version.texi @@ -1,10 +1,10 @@ @ignore -Copyright (C) 1988-2018 Free Software Foundation, Inc. +Copyright (C) 1988-2019 Free Software Foundation, Inc. @end ignore @set EDITION 8.0 @set VERSION 8.0 -@set UPDATED 30 November 2018 -@set UPDATED-MONTH November 2018 +@set UPDATED 6 March 2019 +@set UPDATED-MONTH March 2019 -@set LASTCHANGE Fri Nov 30 22:50:53 EST 2018 +@set LASTCHANGE Wed Mar 6 09:51:02 EST 2019 diff --git a/subst.c b/subst.c index 4962d2f5..45a05f6d 100644 --- 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-2018 Free Software Foundation, Inc. +/* Copyright (C) 1987-2019 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -7055,6 +7055,11 @@ parameter_brace_expand_rhs (name, value, op, quoted, pflags, qdollaratp, hasdoll splitting, we want to quote the value we return appropriately, like the other expansions this function handles. */ w->word = (quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT)) ? quote_string (t1) : quote_escapes (t1); + /* If we have something that's non-null, that's not a quoted null string, + and we're not going to be performing word splitting (we know we're not + because the operator is `='), we can forget we saw a quoted null. */ + if (w->word && w->word[0] && QUOTED_NULL (w->word) == 0) + w->flags &= ~W_SAWQUOTEDNULL; free (t1); return w; @@ -8896,7 +8901,7 @@ parameter_brace_expand (string, indexp, quoted, pflags, quoted_dollar_atp, conta /* All the cases where an expansion can possibly generate an unbound variable error. */ - if (want_substring || want_patsub || want_casemod || c == '#' || c == '%' || c == RBRACE) + if (want_substring || want_patsub || want_casemod || c == '@' || c == '#' || c == '%' || c == RBRACE) { if (var_is_set == 0 && unbound_vars_is_error && ((name[0] != '@' && name[0] != '*') || name[1]) && all_element_arrayref == 0) { @@ -9317,9 +9322,14 @@ param_expand (string, sindex, quoted, expanded_something, identical to $@ */ if (expand_no_split_dollar_star && quoted == 0 && ifs_is_set == 0 && (pflags & PF_ASSIGNRHS)) { - /* Posix interp 888: RHS of assignment, IFS unset */ - temp = string_list_dollar_at (list, Q_DOUBLE_QUOTES, pflags); - tflag |= W_SPLITSPACE; + /* Posix interp 888: RHS of assignment, IFS unset: no splitting, + separate with space */ + temp1 = string_list_dollar_star (list, quoted, pflags); + temp = temp1 ? quote_string (temp1) : temp1; + /* XXX - tentative - note that we saw a quoted null here */ + if (temp1 && *temp1 == 0 && QUOTED_NULL (temp)) + tflag |= W_SAWQUOTEDNULL; + FREE (temp1); } else if (expand_no_split_dollar_star && quoted == 0 && ifs_is_null && (pflags & PF_ASSIGNRHS)) { @@ -9333,6 +9343,10 @@ param_expand (string, sindex, quoted, expanded_something, /* Posix interp 888: RHS of assignment, IFS set to non-null value */ temp1 = string_list_dollar_star (list, quoted, pflags); temp = temp1 ? quote_string (temp1) : temp1; + + /* XXX - tentative - note that we saw a quoted null here */ + if (temp1 && *temp1 == 0 && QUOTED_NULL (temp)) + tflag |= W_SAWQUOTEDNULL; FREE (temp1); } /* XXX - should we check ifs_is_set here as well? */ @@ -10314,7 +10328,7 @@ add_twochars: this is when we are going to be performing word splitting, since we have to preserve a null argument if the next character will cause word splitting. */ - if (temp == 0 && quoted_state == PARTIALLY_QUOTED && quoted == 0 && (word->flags & W_NOSPLIT) == 0 && (word->flags & W_EXPANDRHS)) + if (temp == 0 && quoted_state == PARTIALLY_QUOTED && quoted == 0 && (word->flags & (W_NOSPLIT|W_EXPANDRHS|W_ASSIGNRHS)) == W_EXPANDRHS) { c = CTLNUL; sindex--; @@ -10373,7 +10387,7 @@ add_twochars: partially quoted; such nulls are discarded. See above for the exception, which is when the string is going to be split. Posix interp 888/1129 */ - if (temp == 0 && quoted_state == PARTIALLY_QUOTED && quoted == 0 && (word->flags & W_NOSPLIT) == 0 && (word->flags & W_EXPANDRHS)) + if (temp == 0 && quoted_state == PARTIALLY_QUOTED && quoted == 0 && (word->flags & (W_NOSPLIT|W_EXPANDRHS|W_ASSIGNRHS)) == W_EXPANDRHS) { c = CTLNUL; sindex--; diff --git a/tests/dollar-at-star b/tests/dollar-at-star index 0f713dc3..3d8791dd 100755 --- a/tests/dollar-at-star +++ b/tests/dollar-at-star @@ -302,4 +302,8 @@ ${THIS_SH} ./dollar-at7.sub # IFS is null ${THIS_SH} ./dollar-star9.sub +# more tests for expansions of $* when not splitting with IFS set or unset and +# null strings as the positional parameters +${THIS_SH} ./dollar-star10.sub + exit 0 diff --git a/tests/dollar-star10.sub b/tests/dollar-star10.sub new file mode 100644 index 00000000..fbd1063d --- /dev/null +++ b/tests/dollar-star10.sub @@ -0,0 +1,79 @@ +oIFS=$IFS + +set -- '' + +unset v +recho ${v= ''} +recho $v +unset v +recho ${v=''} +recho $v +unset v +recho ${v= $*} +recho $v +unset v +recho ${v=$*} +recho $v +unset v +recho ${v='' } +recho $v +unset v +recho ${v= '' } +recho $v +unset v +recho ${v=$* } +recho $v +unset v +recho ${v= $* } +recho $v + +unset IFS + +unset v +recho ${v= ''} +recho $v +unset v +recho ${v=''} +recho $v +unset v +recho ${v= $*} +recho $v +unset v +recho ${v=$*} +recho $v +unset v +recho ${v='' } +recho $v +unset v +recho ${v= '' } +recho $v +unset v +recho ${v=$* } +recho $v +unset v +recho ${v= $* } +recho $v + +unset -v v +IFS=$oIFS + +# This shouldn't output anything +set -- '' '' + +unset -v v +recho ${v=$*} +unset -v v +recho ${v= $*} +unset -v v +recho ${v=$* } +unset -v v +recho ${v= $* } + +unset -v v IFS +recho ${v=$*} +unset -v v +recho ${v= $*} +unset -v v +recho ${v= $* } +unset -v v +recho ${v= $*}