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

Re: bug with chpwd/allexport



Hi,

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

Granted.

> 
> :There is a simple workaround:
> :function chpwd () {
> :     setopt LOCALOPTIONS
> :     unsetopt AUTONAMEDIRS
> :     unsetopt ALLEXPORT
> :     FOO=$PWD
> :     echo $FOO
> :}
> 
> Simple workaround 1:
>     chpwd () {
>         echo $PWD
>     }
> 
> Simple workaround 2 (in case we're only seeing a fragment of your chpwd() ):
>     chpwd() {
>         local FOO=$PWD
>         echo $FOO
>     }

The 'echo $FOO' was just an EXAMPLE to reproduce the problem! Think of a
more complicated way someone builds the variable FOO and doesn't want to
put it all on one line. BTW if the second workaround you suggest works,
then it is a bug. The manpage states clearly, that a local variable is
still exported if the ALLEXPORT option is set and the variable was
prviously unset.

> BTW, do you have a good reason for setopt'ing ALL_EXPORT?  Why polute your
> environment in that manner?

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