commit bash-20190822 snapshot

This commit is contained in:
Chet Ramey
2019-08-23 09:52:32 -04:00
parent 3ec948312d
commit d11d79842a
9 changed files with 147 additions and 36 deletions
+15
View File
@@ -6460,3 +6460,18 @@ execute_cmd.c
lib/readline/colors.c
- _rl_print_color_indicator: eliminate one use of S_ISLNK.
Report and fix from Christian Biesinger <cbiesinger@google.com>
8/22
----
variables.c
- push_posix_temp_var: change to use bind_variable and modify variables
at the current local scope or create and modify variables at the
global scope, as if a standalone assignment statement had been
executed. This restores some bash-4.4 backwards compatibility with
respect to posix-mode assignment statements preceding special
builtins and shell functions. The bash-5.0 behavior, while perhaps
defensible, caused too many compatibility problems. Originally
prompted by several discussions with Martijn Dekker; the current
incarnation and tests based on a report to Debian BTS from
Thorsten Glaser <tg@mirbsd.de>
+1
View File
@@ -1429,6 +1429,7 @@ tests/varenv13.sub f
tests/varenv14.sub f
tests/varenv15.sub f
tests/varenv15.in f
tests/varenv16.sub f
tests/version f
tests/version.mini f
tests/vredir.tests f
+1 -1
View File
@@ -2334,7 +2334,7 @@ is an array variable subscripted with @samp{@@} or @samp{*},
the operation is applied to each member of the
array in turn, and the expansion is the resultant list.
The result of the expansion is subject to word splitting and pathname
The result of the expansion is subject to word splitting and filename
expansion as described below.
@end table
+1 -1
View File
@@ -1,4 +1,4 @@
BUILD_DIR=/usr/local/build/chet/bash/bash-current
BUILD_DIR=/usr/local/build/bash/bash-current
THIS_SH=$BUILD_DIR/bash
PATH=$PATH:$BUILD_DIR
+29 -6
View File
@@ -146,12 +146,19 @@ declare -x foo="abc"
inside: declare -x var="value"
outside: declare -- var="one"
inside: declare -x var="value"
outside: declare -x var="value"
inside: declare -- var="local"
outside: declare -x var="global"
foo=<unset> environment foo=
foo=foo environment foo=foo
foo=foo environment foo=foo
outside: declare -- var="outside"
inside: declare -x var="inside"
outside: declare -- var="outside"
outside 1.0: var=one
outside 1.1: var=one
inside func: var=two
outside 2.0: var=two
inside func: var=two
outside 2.1: var=two
inside func1: var=value
outside 3.0: var=value
inside func2: var=global
outside 4.0: var=outside
./varenv13.sub: line 3: `var[0]': not a valid identifier
./varenv13.sub: line 3: `var[@]': not a valid identifier
./varenv13.sub: line 1: declare: var: not found
@@ -207,6 +214,22 @@ after source 1: a b c d e f g h i j k l m n o p q r s t u v w x y z
varenv15.in: before set: one two three four five six seven eight nine ten
varenv15.in: after set: a b c d e f g h i j k l m n o p q r s t u v w x y z
after source 2: a b c d e f g h i j k l m n o p q r s t u v w x y z
foo=showfoo environment foo=showfoo
foo=showfoo environment foo=showfoo
foo=showfoo environment foo=showfoo
outside: foo=<unset>
posix mode
foo=showfoo environment foo=showfoo
outside 1.0: foo=<unset>
foo=showfoo environment foo=showfoo
foo=showfoo environment foo=showfoo
outside 1.1: foo=foo
foo=<unset> environment foo=
outside 2.0: foo=<unset>
foo=foo environment foo=foo
foo=foo environment foo=foo
outside 2.1: foo=foo
a=z
a=b
a=z
+2
View File
@@ -242,5 +242,7 @@ ${THIS_SH} ./varenv14.sub
${THIS_SH} ./varenv15.sub
${THIS_SH} ./varenv16.sub
# make sure variable scoping is done right
tt() { typeset a=b;echo a=$a; };a=z;echo a=$a;tt;echo a=$a
+50 -17
View File
@@ -50,10 +50,11 @@ unset -f func
# this will probably change behavior; export shouldn't behave like this when
# not in posix mode and the sequencing is probably wrong in posix mode. since
# export is a special builtin, the variable assignment should modify the
# global variable, leaving the local variable unchanged. all shells, including
# bash, modify the local variable; bash is the only one that propagates the
# value out to the calling environment. bash does that only when in posix
# mode.
# local variable, as if a standalone assignment statement had been executed
# (posix modifying "the current execution environment") leaving the global
# variable unchanged. all shells, including bash, modify the local variable;
# bash was the only one that propagates the value out to the calling
# environment, but no longer does so.
func()
{
@@ -72,7 +73,7 @@ unset -f func
func()
{
local var=local
var=global :
var=inside :
echo -n 'inside: ' ; declare -p var
}
@@ -83,18 +84,50 @@ echo -n 'outside: ' ; declare -p var
unset -v var
unset -f func
# test whether or not temporary environment assignments are exported
# in posix mode
showfoo()
func()
{
printf %s "foo=${foo-<unset>}"
echo -n ' environment foo='
printenv foo || echo
echo -n 'inside func: ' ; echo "var=${var-<unset>}"
}
unset foo
showfoo
foo=foo showfoo
showfoo
unset -v foo
unset -f showfoo
unset -v var
var=one :
echo -n 'outside 1.0: ' ; echo "var=${var-<unset>}"
unset -v var
var=one eval ':'
echo -n 'outside 1.1: ' ; echo "var=${var-<unset>}"
unset -v var
var=two func
echo -n 'outside 2.0: ' ; echo "var=${var-<unset>}"
var=global
var=two func
echo -n 'outside 2.1: ' ; echo "var=${var-<unset>}"
unset -v var
unset -f func
func1()
{
var=value export var
echo -n 'inside func1: ' ; echo "var=${var-<unset>}"
}
var=outside
func1
echo -n 'outside 3.0: ' ; echo "var=${var-<unset>}"
unset -v var
unset -f func1
func2()
{
local var=local
var=global :
echo -n 'inside func2: ' ; echo "var=${var-<unset>}"
}
var=outside
func2
echo -n 'outside 4.0: ' ; echo "var=${var-<unset>}"
+38
View File
@@ -0,0 +1,38 @@
# test whether or not temporary environment assignments are exported
# in posix mode. works now, posix says it will not work in the future
show2()
{
printf %s "foo=${foo-<unset>}"
echo -n ' environment foo='
printenv foo || echo
}
showfoo()
{
local foo
foo=showfoo show2
}
unset foo
showfoo
foo=foo showfoo
showfoo
echo outside: "foo=${foo-<unset>}"
echo ; echo 'posix mode'
set -o posix
unset foo
showfoo
echo outside 1.0: "foo=${foo-<unset>}"
foo=foo showfoo
showfoo
echo outside 1.1: "foo=${foo-<unset>}"
unset foo
show2
echo outside 2.0: "foo=${foo-<unset>}"
foo=foo show2
show2
echo outside 2.1: "foo=${foo-<unset>}"
+10 -11
View File
@@ -324,6 +324,7 @@ static void push_func_var __P((PTR_T));
static void push_builtin_var __P((PTR_T));
static void push_exported_var __P((PTR_T));
/* This needs to be looked at again. */
static inline void push_posix_tempvar_internal __P((SHELL_VAR *, int));
static inline int find_special_var __P((const char *));
@@ -4600,7 +4601,6 @@ push_posix_temp_var (data)
var = (SHELL_VAR *)data;
#if 0 /* TAG:bash-5.1 */
/* Just like do_assignment_internal(). This makes assignments preceding
special builtins act like standalone assignment statements when in
posix mode, satisfying the posix requirement that this affect the
@@ -4612,13 +4612,6 @@ push_posix_temp_var (data)
Set binding_table appropriately. It doesn't matter whether it's correct
if the variable is local, only that it's not global_variables->table */
binding_table = v->context ? shell_variables->table : global_variables->table;
#else
binding_table = global_variables->table;
if (binding_table == 0)
binding_table = global_variables->table = hash_create (VARIABLES_HASH_BUCKETS);
v = bind_variable_internal (var->name, value_cell (var), binding_table, 0, ASS_FORCE|ASS_NOLONGJMP);
#endif
/* global variables are no longer temporary and don't need propagating. */
if (binding_table == global_variables->table)
@@ -4628,9 +4621,6 @@ push_posix_temp_var (data)
{
v->attributes |= var->attributes;
v->attributes &= ~att_tempvar; /* not a temp var now */
#if 1 /* TAG:bash-5.1 code doesn't need this, disable for bash-5.1 */
v->context = (binding_table == global_variables->table) ? 0 : shell_variables->scope;
#endif
}
if (find_special_var (var->name) >= 0)
@@ -4770,6 +4760,15 @@ merge_temporary_env ()
dispose_temporary_env (posixly_correct ? push_posix_temp_var : push_temp_var);
}
/* Temporary function to use if we want to separate function and special
builtin behavior. */
void
merge_function_temporary_env ()
{
if (temporary_env)
dispose_temporary_env (push_temp_var);
}
void
flush_temporary_env ()
{