Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: fpath+="${(u)fpath[@]}" can hog system
- X-seq: zsh-workers 37817
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: fpath+="${(u)fpath[@]}" can hog system
- Date: Wed, 27 Jan 2016 14:50:41 -0800
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:date:in-reply-to:comments:references:to:subject :mime-version:content-type; bh=cKGEk/w8FPuWZ2Qtp37TOgyk3mTA0gzIxui5lwpi9gk=; b=fWGgrlnUnKAKJ6f7Mq2tpRtt58N0AsHwsVdXXco0y5K7NAa0k12sfb8QJpwcKUbZRw /870Nyc5btanwgwltIks+qdh8FhMR3GzykjG45468g+eQ5ALYzVok/M1WCSnAkb26RkR eaQdtHJzzcWliCsgj3LR7HPEtWm+mf8mma5z2D1DM5oXcRJ5Zz+cdMeBDY6cQPOi+ugf y//Uyf4UkvYNMgY6A1hNJEwFJboaikUddLThwC4p70kLwbx84rGzUpuiM6bU/jnZakU0 wbBBluR6V9mZpZ//gX024Q0Qk+tTYbA9mJSClCM2Noyh+2SjZRAu2j3kxXi58JWllDv/ py2w==
- In-reply-to: <CAKc7PVB6x-Eip=v1ctT_Ehf762MXHgBdxP1d7AwcQKX=B5sg8w@mail.gmail.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <CAKc7PVB6x-Eip=v1ctT_Ehf762MXHgBdxP1d7AwcQKX=B5sg8w@mail.gmail.com>
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
resources.
If what you mean is to append new elements to the array, you want array
assignment syntax:
fpath+=("${(u)fpath[@]}")
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
no-op.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author