I'm not sure if this is a bug or not, but set builtin prints dynamic variables in their last state, but not actual.
For example:
[rra...@dhcp-lab-170 bash-4.0]$ set | grep BASH_CMDS
BASH_CMDS=()
[rra...@dhcp-lab-170 bash-4.0]$ hash
hits    command
   4    /bin/grep
   1    /bin/egrep
   1    /usr/bin/vim
   1    /usr/bin/man
   2    /usr/bin/make
   3    /usr/bin/gdb
[rra...@dhcp-lab-170 bash-4.0]$ echo ${BASH_CMDS[*]}
/bin/grep /bin/egrep /usr/bin/vim /usr/bin/man /usr/bin/make /usr/bin/gdb
[rra...@dhcp-lab-170 bash-4.0]$ set | grep BASH_CMDS
BASH_CMDS=([grep]="/bin/grep" [egrep]="/bin/egrep" [vim]="/usr/bin/vim" [man]="/usr/bin/man" [make]="/usr/bin/make" [gdb]="/usr/bin/gdb" )

On first set call the BASH_CMDS was set to empty, but in fact internal hash isn't same. This is done, because set (its print_variables) does not reread dynamic variables values.
Question is, if this behavior is what we want or not.

In the case of BASH_CMDS dynamic variable this is not so much interesting (and funny). Dynamic variable RANDOM is much more funny in this case, you know :)

So, what we do with this? I'm for rereading variables in set builtin.

RR


Reply via email to