Subject: Re: /usr/bin/which is a csh script!!?!
To: NetBSD-current Discussion List <current-users@netbsd.org>
From: Andrew Brown <atatat@atatdot.net>
List: current-users
Date: 05/01/2003 09:21:51
>> imho, the real bug is shells that provide aliases but don't provide
>> something like which(1) as a builtin, which is the only really wrong
>> case (shells that provide aliases and will only tell you that
>> something is an alias aside).  which shells are the broken ones?
>
>The only shell so broken in any official NetBSD release is "csh" itself,
>which is why there's a which(1) script just for it.

in which case it will mostly get the job done, except for changes made
to the path or aliases added at the command line.

bleah.  csh obviously knows what to do.  i wonder how hard it would be
to make it tell you.

>The real problem that you (and perhaps others) seem to have missed
>completely is that there are lots of users who have either grown up
>accustomed to typing "which" to find out what kind of thing some command
>is, or have been taught to do so by some unthinking mentor who grew up
>doing so.  As a result those who use a "Real Shell(tm)" with a "command"
>or "whence" built-in that "Does The Right Thing(tm)", will still end up
>trying to use "which" instead, and thus why even on my systems where
>I've obliterated and eliminated all traces of "csh", I still have a
>"which" command, now implemented as a /bin/sh script.  :-)

what does your sh script do, pray tell?  does it do the "fascist"
equivalent of "you haf invoked me, zo i shall parz your path, and vill
tell you zomething zat might be wrong", or is it more like this:

    shell=$(echo $(ps -oucomm= -p$(ps -oppid= -p$$)))
    echo -n "$shell users must use the "
    case "$shell" in
	sh)         echo '"type" command, not "which"'
		    exit 0
		    ;;
	ksh)        echo '"type" command or "whence" commands, not "which"'
		    exit 0
		    ;;
	zsh)        echo '"where", "which", or "type" command, not "which"'
		    exit 0
    ....

-- 
|-----< "CODE WARRIOR" >-----|
codewarrior@daemon.org             * "ah!  i see you have the internet
twofsonet@graffiti.com (Andrew Brown)                that goes *ping*!"
werdna@squooshy.com       * "information is power -- share the wealth."