From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25136 invoked by alias); 20 Jun 2011 15:45:03 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 29498 Received: (qmail 20486 invoked from network); 20 Jun 2011 15:44:50 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS autolearn=ham version=3.3.1 Received-SPF: pass (ns1.primenet.com.au: SPF record at lorien.comfychair.org designates 173.8.144.98 as permitted sender) Date: Mon, 20 Jun 2011 08:44:44 -0700 From: Danek Duvall To: Peter Stephenson Cc: zsh-workers@zsh.org Subject: Re: _multi_parts and -q Message-ID: <20110620154444.GB3154@lorien.comfychair.org> Mail-Followup-To: Danek Duvall , Peter Stephenson , zsh-workers@zsh.org References: <20110617215008.GA3154@lorien.comfychair.org> <20110618205218.093eb2f8@pws-pc.ntlworld.com> <110618130334.ZM19744@torch.brasslantern.com> <20110618220723.6559e606@pws-pc.ntlworld.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20110618220723.6559e606@pws-pc.ntlworld.com> User-Agent: Mutt/1.5.20 (2010-04-22) On Sat, Jun 18, 2011 at 10:07:23PM +0100, Peter Stephenson wrote: > On Sat, 18 Jun 2011 13:03:34 -0700 > Bart Schaefer wrote: > On Jun 18, 8:52pm, Peter Stephenson wrote: > > } > > } _tst() { > > } local expl_type="stuff" > > } local -a datasetlist > > } datasetlist=(foo bar rod stuff) > > } local pref > > } [[ $PREFIX = */* ]] && pref=${PREFIX%/*} > > } [[ -n $pref ]] && datasetlist=($pref/${^datasetlist}) > > } _wanted dataset expl "$expl_type" _multi_parts -S/ -q / datasetlist; > > } } > > } > > } simply to get strings to compile. I don't think that should matter. > > > > I get Danek's reported behavior if the strings in datasetlist actually > > contain the separator. Try the above with > > > > datasetlist=(xy/foo xy/bar yx/rod stuff xy/yx/xy) > > > > So perhaps Danek's problem is with the input data? For context, this in my _zfs_dataset function, which at the moment passes neither -S nor -q to _multi_parts, but I tried doing that to try to get the slash auto-removed. datasetlist contains the entire list of datasets on the system, mostly because it's cheaper to generate the entire list once instead of at each level. So it contains data like xy xy/foo xy/foo/bar xy/foo/baz xy/qux xy/qux/baz just like a directory structure. Then if I type "x", I get "xy/". If I type "/", I still have only one slash, but if I hit space or return, then the slash stays. And "xy/" is not valid, and the command complains. Which I guess is this observation: > I'm seeing something similar with the "xy/" bit with that data, i.e > completing "x" produces "xy/" with a non-removable "/". > I think the issue is that "xy/foo", "xy/bar" etc. look like a set of > ambiguous completions with "xy/" as prefix --- and in *that* case the > "/" isn't special, it's just part of the input string. (Possibly you > can see some behaviour that disagrees with this hypothesis.) > > So the reason I wasn't seeing it is that I was only offering completions > for the current level, i.e. I'd only be offering "xy", "yx" and "stuff" > at this point, after which the "/" is a suffix & separator with the > expected behaviour. > > So if it's possible to generate the completions in that fashion (some > more sophisticated variant of the ${PREFIX%/*} business in the function > I was using), I think that would be a workaround. How can I do that without regenerating datasetlist multiple times -- calling zfs list over and over again is not cheap (but not really something I want to cache using _store_cache, etc, either, if for no other reason than I have no way of knowing whether the cache is invalid). Thanks, Danek