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>
+
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
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
-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
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
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
${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
# 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()
{
func()
{
local var=local
- var=global :
+ var=inside :
echo -n 'inside: ' ; 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>}"
--- /dev/null
+# 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>}"
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 *));
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
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)
{
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)
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 ()
{