commit bash-20210127 snapshot

This commit is contained in:
Chet Ramey
2021-02-01 15:09:07 -05:00
parent 4be5608573
commit fcad1d1e84
10 changed files with 90 additions and 26 deletions
+12
View File
@@ -9450,3 +9450,15 @@ lib/glob/glob.c
subpattern to be cut off when calling skipname
- extglob_skipname,wextglob_skipname: some cleanups so the code is
closer to identical for the single-byte and wide character versions
2/1
---
execute_cmd.c
- execute_simple_command: in posix mode, if we have a variable
assignment error while assigning into the temporary environment (e.g.,
assigning to a readonly variable), a non-interactive shell running a
special builtin exits; a non-interactive shell running anything else
jumps back to the top level. A shell compiled with -DSTRICT_POSIX
exits unconditionally.
- execute_simple_command: make sure posix mode sets $? to non-zero
if a variable assignment error occurs preceding a non-special builtin
+1
View File
@@ -1092,6 +1092,7 @@ tests/extglob3.tests f
tests/extglob3.right f
tests/extglob4.sub f
tests/extglob5.sub f
tests/extglob6.sub f
tests/func.tests f
tests/func.right f
tests/func1.sub f
-3
View File
@@ -84,7 +84,6 @@ array_create()
ARRAY_ELEMENT *head;
r = (ARRAY *)xmalloc(sizeof(ARRAY));
r->type = array_indexed;
r->max_index = -1;
r->num_elements = 0;
r->lastref = (ARRAY_ELEMENT *)0;
@@ -134,7 +133,6 @@ ARRAY *a;
if (a == 0)
return((ARRAY *) NULL);
a1 = array_create();
a1->type = a->type;
a1->max_index = a->max_index;
a1->num_elements = a->num_elements;
for (ae = element_forw(a->head); ae != a->head; ae = element_forw(ae)) {
@@ -161,7 +159,6 @@ ARRAY_ELEMENT *s, *e;
arrayind_t mi;
a = array_create ();
a->type = array->type;
for (mi = 0, p = s, i = 0; p != e; p = element_forw(p), i++) {
n = array_create_element (element_index(p), element_value(p));
+1 -2
View File
@@ -27,10 +27,9 @@
typedef intmax_t arrayind_t;
enum atype {array_indexed, array_assoc}; /* only array_indexed used */
enum atype {array_indexed, array_assoc}; /* not used */
typedef struct array {
enum atype type;
arrayind_t max_index;
int num_elements;
struct array_element *head;
+4 -1
View File
@@ -7819,7 +7819,10 @@ a value to a readonly variable.
@item
A non-interactive shell exits with an error status if a variable
assignment error occurs in an assignment statement preceding a special
builtin, but not with any other simple command.
builtin, but not with any other simple command. For any other simple
command, the shell aborts execution of that command, and execution continues
at the top level ("the shell shall not perform any further processing of the
command in which the error occurred").
@item
A non-interactive shell exits with an error status if the iteration
+17 -16
View File
@@ -3013,16 +3013,13 @@ eval_arith_for_expr (l, okp)
int r;
char *expr, *temp;
#if 1 /* TAG: bash-5.2 */
expr = l->next ? string_list (l) : l->word->word;
temp = expand_arith_string (expr, Q_DOUBLE_QUOTES|Q_ARITH);
if (l->next)
free (expr);
new = make_word_list (make_word (temp), (WORD_LIST *)NULL);
free (temp);
#else
new = expand_words_no_vars (l);
#endif
if (new)
{
if (echo_command_at_execute)
@@ -3791,10 +3788,7 @@ execute_arith_command (arith_command)
t = (char *)NULL;
new = arith_command->exp;
if (new->next)
exp = t = string_list (new); /* just in case */
else
exp = new->word->word;
exp = (new->next) ? (t = string_list (new)) : new->word->word;
exp = expand_arith_string (exp, Q_DOUBLE_QUOTES|Q_ARITH);
FREE (t);
@@ -4459,16 +4453,23 @@ execute_simple_command (simple_command, pipe_in, pipe_out, async, fds_to_close)
}
/* In POSIX mode, assignment errors in the temporary environment cause a
non-interactive shell to exit. */
#if 1
if (posixly_correct && builtin_is_special && interactive_shell == 0 && tempenv_assign_error)
#else
/* This is for strict posix conformance. */
if (posixly_correct && interactive_shell == 0 && tempenv_assign_error)
#endif
non-interactive shell executing a special builtin to exit and a non-
interactive shell to otherwise jump back to the top level. This is what
POSIX says to do for variable assignment errors, and errors in assigning
to the temporary environment are treated as variable assignment errors. */
if (posixly_correct && tempenv_assign_error)
{
last_command_exit_value = EXECUTION_FAILURE;
jump_to_top_level (ERREXIT);
#if defined (STRICT_POSIX)
jump_to_top_level ((interactive_shell == 0) ? ERREXIT : DISCARD);
#else
if (interactive_shell == 0 && builtin_is_special)
jump_to_top_level (ERREXIT);
else if (interactive_shell == 0)
jump_to_top_level (DISCARD);
else
jump_to_top_level (DISCARD);
#endif
}
tempenv_assign_error = 0; /* don't care about this any more */
+2 -4
View File
@@ -177,11 +177,9 @@ after non-special builtin: 0
after special builtin: 0
./errors7.sub: line 27: x: readonly variable
./errors7.sub: line 21: x: readonly variable
./errors7.sub: line 21: notthere: command not found
after no such command: 127
after no such command: 1
./errors7.sub: line 23: x: readonly variable
echo builtin
after non-special builtin: 0
after non-special builtin: 1
./errors7.sub: line 25: x: readonly variable
./errors7.sub: line 27: x: readonly variable
./errors8.sub: eval: line 7: syntax error: unexpected end of file
+10
View File
@@ -114,3 +114,13 @@ a b c
.x .y .z a b c
.x .y .z a b c
*
.. .b a
.. .b a
a .. .b
. .. .b
. .. .b
.. .b a
.. .b a
a .. .b
. .. .b
. .. .b
+2
View File
@@ -389,4 +389,6 @@ ${THIS_SH} ./extglob4.sub
${THIS_SH} ./extglob5.sub
${THIS_SH} ./extglob6.sub
exit 0
+41
View File
@@ -0,0 +1,41 @@
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# issues with ? matching "." in certain special circumstances with dotglob set
shopt -s dotglob extglob
DIR=$TMPDIR/extglob-$$
mkdir $DIR
cd $DIR
touch a .b
echo @(?|.?)
echo @(.?|?)
echo ? .?
echo .*
echo \.*
shopt -u dotglob
echo @(?|.?)
echo @(.?|?)
echo ? .?
echo .*
echo \.*
cd $OLDPWD
rm -rf $DIR