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

Re: Possibly dumb question... Constructing PATH



Christopher Browne wrote:

> I'm redoing some of my .rc files, and was wondering if there's a
> common idiom for "add that path to PATH, if it's missing"?
 
I think the idiom is to use a unique array. That is an array that will keep
only the first occurrence of each (possibly duplicate) value.

typeset -U path
path=($HOME/bin /opt/bin /other/path $path)

See zshbuiltins man page for more on typeset.

-- 

John Eikenberry
[jae@xxxxxxxx - http://zhar.net]
[PGP public key @ http://zhar.net/jae_at_zhar_net.gpg]
______________________________________________________________
"Perfection is attained, not when no more can be added, but when no more 
 can be removed." -- Antoine de Saint-Exupery

Attachment: signature.asc
Description: Digital signature



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