From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21431 invoked from network); 27 Apr 2000 22:10:59 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 27 Apr 2000 22:10:59 -0000 Received: (qmail 17295 invoked by alias); 27 Apr 2000 22:10:49 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 10986 Received: (qmail 17275 invoked from network); 27 Apr 2000 22:10:48 -0000 From: "Bart Schaefer" Message-Id: <000427150916.ZM21554@candle.brasslantern.com> Date: Thu, 27 Apr 2000 15:09:16 -0700 In-Reply-To: <000501bfb01e$76728f70$21c9ca95@mow.siemens.ru> Comments: In reply to "Andrej Borsenkow" "RE: Completion function directories" (Apr 27, 11:59am) References: <000501bfb01e$76728f70$21c9ca95@mow.siemens.ru> X-Mailer: Z-Mail Lite (5.0.0 30July97) To: Subject: Re: Completion function directories MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Apr 27, 11:59am, Andrej Borsenkow wrote: > Subject: RE: Completion function directories > > > > Much earlier, Sven wrote: > > } [...] Andrej comes and says that we should put all the GNU commands > > } on the side... > > > > This brings up a a question of whether we should have helper functions > > for setting/testing the _is_gnu assoc, like happens now in _make and > > _diff_options, or to set up the "standard completion environment" like > > in _main_complete and _complete_help. > > I am not sure I understand what do you mean under "standard completion > environment" in this respect. The two lines of setopts that have to appear at the top of each of several of the completion functions to be sure all the globs and parameter refs work as expected in all the rest of the functions those call. My idea was to write a function: _standard_completer_setopts () { unsetopt localoptions # This is the problem part setopt nullglob rcexpandparam extendedglob unsetopt markdirs globsubst shwordsplit nounset ksharrays } Then there's only one place to edit if we ever need to change the setopts used by all the completion scripts -- but the present unpredictable behavior of `unsetopt localoptions' makes this idea unworkable. > I believe, in all cases when it is > possible we need automatic test for GNU utilities so, that completion > really works "out of the box". And only when it's not possible - last > resort like styles for particular command. Following the same sort of suggestion as above, we'd have something like _detect_gnu () { (( $+_is_gnu )) || typeset -gA _is_gnu if (( ! $+_is_gnu[$1] )) then if [[ $(_call version "$@" /dev/null) = *GNU* ]] then _is_gnu[$1]=yes else _is_gnu[$1]= fi fi [[ $_is_gnu[$1] = yes ]] } And then _make would use if _detect_gnu $words[1] -v -f /dev/null; then and _diff_options would use if _detect_gnu $cmd -v; then and so on for any other completion functions that needed to notice GNU.