]> git.ipfire.org Git - thirdparty/bash.git/commitdiff
commit bash-20190822 snapshot
authorChet Ramey <chet.ramey@case.edu>
Fri, 23 Aug 2019 13:52:32 +0000 (09:52 -0400)
committerChet Ramey <chet.ramey@case.edu>
Fri, 23 Aug 2019 13:52:32 +0000 (09:52 -0400)
CWRU/CWRU.chlog
MANIFEST
doc/bashref.texi
tests/RUN-ONE-TEST
tests/varenv.right
tests/varenv.tests
tests/varenv12.sub
tests/varenv16.sub [new file with mode: 0644]
variables.c

index df23c16989497e1a97983abaa135066a087d9d55..e0b26a1384283e943a4e8faa9ab81150a16bf2ed 100644 (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>
+
index 75c1ef9020f69ef0f2cddcd4ef1fb2c856bd0eea..eaa6c60b8f78807d95190eded5547aedf8ea934a 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -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
index 965b758cbce5821c1a6d727b1b0aff1a388498e0..d5beccd73fdc0ffd0bb1b9fc360e3b87c367fee9 100644 (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
 
index 0b06381072414283266cf5d055a42ac14b9b6da6..c8bef8dd12533217b1b65fc20d00f3d1cc1b81e7 100755 (executable)
@@ -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
 
index 159a87737dd3276a36ecc77684bea061ddfe4c8e..b86202273c05be7dbef49e88208f0d36836141c1 100644 (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
index 34b8559633116b123a8eda2d994b28cf58c021bf..5c69bbf4ac73684b38c598759ed940cde4f856b1 100644 (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
index edba3c9469aee22829cb0e3fe6d3bc4b3a992ac9..7e384ac770db8b30579a055a7febba32769b2276 100644 (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>}"
diff --git a/tests/varenv16.sub b/tests/varenv16.sub
new file mode 100644 (file)
index 0000000..b3c342c
--- /dev/null
@@ -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>}"
index 77a61c4f6d0898581f70a1a394d62a2dddd7b10b..cbdd2d270b036fb015106c4c24c7828a4ad18d7f 100644 (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 ()
 {