Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

bug with chpwd/allexport



Hi folks,

a while ago I discovered a bug in zsh 3.05 (I was working with the
NT version by Amol Deshpande). I'm not sure if Amol reported it here
already. The problem is, that is you have the ALLEXPORT and the
AUTONAMEDIRS option set and use a variable in your chpwd function
(e.g. to build a string to print it on the windows title bar),
the variable is immediately put into the hashtable for named 
directories. And if you have a '%~' in your prompt, it is replaced
with the name of the variable. You can reproduce it this way:

# export PS1='%~>'
~ > setopt ALLEXPORT
~ > setopt AUTONAMEDIRS
~ > function chpwd () {
> FOO=$PWD
> echo $FOO
> }
~ > cd /etc
/etc
$FOO >

Have a look at the prompt on the last line. I've reproduced
this with NT and LINUX, so it is not a porting problem.
I had a look at the source code but could not see an easy way
to fix this. At first I thought, one could handle the zsh-
specific function in a special way to prevent variables used
in there from going into hashtables, but the user could call
the function himself. This would entail a lot of changes
probably not worth the effort.

What I suggest is: Just document it in the manpage. There
should be at least a hint on this problem where the two
options are described and in the description of the chpwd
function.

There is a simple workaround:

function chpwd () {
     setopt LOCALOPTIONS
     unsetopt AUTONAMEDIRS
     unsetopt ALLEXPORT
     FOO=$PWD
     echo $FOO
}

Please respond to me by email.

Bye

Dominik
-- 
------------------------------------------------------------------------
Dominik Vogt                                 phone:        07031/14-4596
Hewlett-Packard GmbH                           fax:        07031/14-3883
Boeblingen Verification Solutions                                       
Herrenberger Str. 130
71034 Boeblingen                             email:  dominik_vogt@xxxxxx
------------------------------------------------------------------------



Messages sorted by: Reverse Date, Date, Thread, Author