[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Dynamic variables and set builtin
From: |
Roman Rakus |
Subject: |
Dynamic variables and set builtin |
Date: |
Fri, 28 Aug 2009 17:36:07 +0200 |
User-agent: |
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1b3pre) Gecko/20090513 Fedora/3.0-2.3.beta2.fc11 Thunderbird/3.0b2 |
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:
[rrakus@dhcp-lab-170 bash-4.0]$ set | grep BASH_CMDS
BASH_CMDS=()
[rrakus@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
[rrakus@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
[rrakus@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
- Dynamic variables and set builtin,
Roman Rakus <=