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

Re: fpath+="${(u)fpath[@]}" can hog system

On Jan 27, 10:36am, Sebastian Gniazdowski wrote:
} repeat 20; do fpath+="${(u)fpath[@]}"; done

Why would you do that?  What's the intended result?

Appending a string to an array creates a single new array element; it
doesn't matter that you've used [@] inside the double quotes, you are
still appending a new single element to the array every time.  Since
the new element consists of all the previous elements joined, it is
always unique and (u) will never filter out anything.

And then all of that will be duplicated as a single colon-separated
string in $FPATH.

Yeah, if you increase the size (in bytes) of $fpath by 20! (factorial),
and then make a copy of that, you are going to consume a buttload of

If what you mean is to append new elements to the array, you want array
assignment syntax:


But even that probably doesn't do what you meant. because unless you have
already done "typeset -U fpath" all the existing elements are still going
to be repeated twice ... and IF you HAVE done "typeset -U" then (u) is a

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