zsh-users
 help / color / mirror / code / Atom feed
* need for a fancier _pick_variant?
@ 2003-10-14  6:29 Danek Duvall
  2003-10-22  6:39 ` Bart Schaefer
  0 siblings, 1 reply; 3+ messages in thread
From: Danek Duvall @ 2003-10-14  6:29 UTC (permalink / raw)
  To: zsh-users

I was debugging why

    % diff -u foo ba<TAB>

failed to complete "bar" on Solaris.  The reason, of course is that
_diff_options calls

    _pick_variant -c diff 'gnu=GNU' unix -v

which doesn't match anything for Solaris diff, so the generic unix diff
options are chosen, and the result is thrown by the -u.

Unfortunately, I don't know of any way of distinguishing Solaris diff by
its output, short of a brittle check of its usage statement.  I can,
however, reliably check what options are available for it by running
"what /usr/bin/diff", noting SunOS, and the OS version.

I tried a very naive

   _pick_variant -c what -r diff solaris=SunOS unix '$(whence diff)'

as the test for an elif clause in _diff_options, but it didn't work.  On
re-reading the man page, I misunderstood what -r did, but that's only
the tip of the iceberg here.

I next tried

  elif [[ $(what $(whence $cmd)) == *SunOS\ 5.<9->* ]]; then

which seems to work pretty nicely.  Would you suggest that as a
solution, or to try to beef up _pick_variant to support running
auxiliary programs as tests?

Hm.  In investigating all this, I noticed that all the completion
directories end up duplicated in $fpath, which seems to be done in
compaudit.  This seems to happen on 4.0.5 on Solaris, 4.1.1 on Solaris,
and 4.1.1 on Linux, FWIW.

Thanks,
Danek


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: need for a fancier _pick_variant?
  2003-10-14  6:29 need for a fancier _pick_variant? Danek Duvall
@ 2003-10-22  6:39 ` Bart Schaefer
  2003-10-22  6:51   ` Dan Nelson
  0 siblings, 1 reply; 3+ messages in thread
From: Bart Schaefer @ 2003-10-22  6:39 UTC (permalink / raw)
  To: zsh-users

[ I've been busy and then away, so catching up on some old stuff. ]

On Oct 13, 11:29pm, Danek Duvall wrote:
}
} _diff_options calls
} 
}     _pick_variant -c diff 'gnu=GNU' unix -v
} 
} which doesn't match anything for Solaris diff, so the generic unix diff
} options are chosen, and the result is thrown by the -u.
}
} Unfortunately, I don't know of any way of distinguishing Solaris diff by
} its output, short of a brittle check of its usage statement.

I don't have access to a Solaris machine.  Does `diff -v` produce the
usage message?  If so, I suggest that you use the "brittle" test just
to decide whether certain options (such as -u) are available, and then
apply a different test to differentiate further.  E.g. (I'm shooting
in the dark here, please edit as necessary):

    local difftype
    _pick_variant -r difftype -c $cmd gnu=GNU extended=' -u ' unix -v
    if [[ $difftype == extended ]]; then
	_pick_variant -r difftype -c what \
	    solaris=SunOS extended $(whence $cmd)
    fi
    case $difftype in
    gnu)
    	# The stuff now in the "if" part of _diff_options
	;;
    solaris)
    	# Your new section for solaris diff
	;;
    extended)
    	# The current "else" part of _diff_options, with -u added
	;;
    *)
    	# The current "else" part of _diff_options
	;;
    esac

You could enhance this a little by adding "solaris=SunOS" to the first 
of those two calls to _pick_variant, which allows the user to set the
"command" style in ":completion:*:diff:*:variant" context to something
that immediately returns "SunOS", thereby avoiding the second attempt.

} Hm.  In investigating all this, I noticed that all the completion
} directories end up duplicated in $fpath, which seems to be done in
} compaudit.  This seems to happen on 4.0.5 on Solaris, 4.1.1 on Solaris,
} and 4.1.1 on Linux, FWIW.

It *shouldn't* happen in compaudit; compaudit only tests things in the
fpath, it doesn't assign to it (except as a `local +h' parameter, which
should be reset when it goes out of scope).


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: need for a fancier _pick_variant?
  2003-10-22  6:39 ` Bart Schaefer
@ 2003-10-22  6:51   ` Dan Nelson
  0 siblings, 0 replies; 3+ messages in thread
From: Dan Nelson @ 2003-10-22  6:51 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-users

In the last episode (Oct 22), Bart Schaefer said:
> [ I've been busy and then away, so catching up on some old stuff. ]
> 
> On Oct 13, 11:29pm, Danek Duvall wrote:
> }
> } _diff_options calls
> } 
> }     _pick_variant -c diff 'gnu=GNU' unix -v
> } 
> } which doesn't match anything for Solaris diff, so the generic unix diff
> } options are chosen, and the result is thrown by the -u.
> }
> } Unfortunately, I don't know of any way of distinguishing Solaris diff by
> } its output, short of a brittle check of its usage statement.
> 
> I don't have access to a Solaris machine.  Does `diff -v` produce the
> usage message?  If so, I suggest that you use the "brittle" test just

Solaris 2.8 and older don't have -u:
/usr/bin/diff: illegal option -- v
usage: diff [-bitw] [-c | -e | -f | -h | -n] file1 file2
       diff [-bitw] [-C number] file1 file2
       diff [-bitw] [-D string] file1 file2
       diff [-bitw] [-c | -e | -f | -h | -n] [-l] [-r] [-s] [-S name] directory1 directory2

2.9 does:
/usr/bin/diff: illegal option -- v
usage: diff [-bitw] [-c | -e | -f | -h | -n | -u] file1 file2
       diff [-bitw] [-C number | -U number] file1 file2
       diff [-bitw] [-D string] file1 file2
       diff [-bitw] [-c | -e | -f | -h | -n | -u] [-l] [-r] [-s] [-S name] directory1 directory2

-- 
	Dan Nelson
	dnelson@allantgroup.com


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-10-22  6:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-10-14  6:29 need for a fancier _pick_variant? Danek Duvall
2003-10-22  6:39 ` Bart Schaefer
2003-10-22  6:51   ` Dan Nelson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).