On 01/11/2014 04:55 PM, Chet Ramey wrote:
On 1/10/14, 6:06 PM, John R. Graham wrote:
Some of the automagically created special array variables (GROUPS and DIRSTACK 
for soer; perhaps others) appear to not be fully initialized. Their values 
don't appear correctly in some corner cases until they've been referenced with 
parameter expansion (I think that's the triggering criteria, anyway). The 
following shell dialog illustrates:
Yes. There are a number of dynamic variables whose values are generated
each time they are referenced.  In most cases, they have no values until
the value is generated the first time.

Thank you. I had determined that it was related to dynamic variables. The only 
code that I've found in Bash that doesn't properly generate the values is the 
dump of all
variables when the "set" built-in command is called with no arguments. There's 
a trivial patch that addresses this issue with (I believe) few adverse side effects
(attached). I'd appreciate a review.

One possibly adverse effect is that variables that did not show up in the list 
before do show up now. They all appear to be from your list. Some examples: 
RANDOM,
SECONDS, LINENO. Don't know whether this would be considered an issue or not.

- John

diff -ubB old/variables.c new/variables.c
--- old/variables.c	2014-01-11 17:29:31.880925869 -0500
+++ new/variables.c	2014-01-11 17:29:40.327592462 -0500
@@ -940,7 +940,10 @@
 
   for (i = 0; list && (var = list[i]); i++)
     if (invisible_p (var) == 0)
+      {
+        var = find_variable(var->name);
       print_assignment (var);
+      }
 }
 
 /* Print LIST (a list of shell functions) to stdout in such a way that

Reply via email to