views:

208

answers:

1

One recommends me the following code apparently only in .zshrc without explaining its purpose clearly.

typeset -U PYTHONPATH

I am interested in how you can use the code in .bashrc. My Bash goes upset about the command.

How can you use the command in Bash?

+3  A: 

That zsh command is useful because zsh can treat the environment variable PYTHONPATH as an actual array of paths. The -U argument to typeset says, then when representing the array in the environment value passed to the program (Python, in this case), only include the first instance of each unique value.

In bash, since array variables aren't exported, PYTHONPATH would be just a normal string variable, containing paths separated by colons. Hence, there is no need to tell bash to use only unique values.

MtnViewMark
**What is the default type of PYTHONPATH if it is not environment variable in Zsh?** -- I have had an idea that PATHs are always env variables both in Zsh and Bash.
Masi
I don't think zsh cares a wit if PYTHONPATH is exported into the environment or not - In either case, whether this variable is treated as an array or not by zsh depends on how you assign to it.While PATH is quite treated specially by both zsh and bash, I don't think either shell knows that PYTHONPATH should afforded similar treatment.
MtnViewMark
I opened a new thread based on this answer at http://superuser.com/questions/4158/how-do-you-search-subnodes-in-pinfo I have had difficulties in finding `typeset` in Zsh's manual.
Masi
The man pages for zsh are split into several sections. typeset is described in zshbuiltins. So, 'man zshbuiltins' will get you the details.
MtnViewMark