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

Re: Completion function directories



Bart Schaefer wrote:

> On Apr 27, 11:59am, Andrej Borsenkow wrote:
>
> ...
> 
> > 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 2>/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.

Hmhm. Does anyone see if and how we could turn this into a more
generic `_check_type' function? Something like:

  local type

  _check_type type $words[1] ... # args?

  case $type in
  GNU) ...
  AIX) ...
  *)   ...
  esac

Would that be possible withou making _check_type too expensive?

Bye
 Sven


--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



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