>X-Envelope-Sender: [EMAIL PROTECTED]

>"Mike A. Harris" wrote:
>> /usr/bin/which is an ELF executable on Red Hat Linux, but I agree
>> that it definitely is not an application that can be expected to
>> be portable.

>Which in Debian GNU/Linux it's a simple shell script that contains:

>----------------
>#!/bin/bash
>unalias -a
>unset -- "$@" &>/dev/null
>enable -n -- "$@" &>/dev/null
>type -p "$@"
>---------------

So it will not do what people who know where "which" comes from expect.

The "real" which is (same file is on *BSD):
/*--------------------------------------------------------------------------*/
#! /usr/bin/csh -f
#
# Copyright(c) 1997, by Sun Microsystems, Inc.
# All rights reserved.
#
#ident "@(#)which.csh   1.4     97/04/23 SMI"
#
#       which : tells you which program you get
#
# Set prompt so .cshrc will think we're interactive and set aliases.
# Save and restore path to prevent .cshrc from messing it up.
set _which_saved_path_ = ( $path )
set prompt = ""
if ( -r ~/.cshrc && -f ~/.cshrc ) source ~/.cshrc
set path = ( $_which_saved_path_ )
unset prompt _which_saved_path_
set noglob
foreach arg ( $argv )
    set alius = `alias $arg`
    switch ( $#alius )
        case 0 :
            breaksw
        case 1 :
            set arg = $alius[1]
            breaksw
        default :
            echo ${arg}: "      " aliased to $alius
            continue
    endsw
    unset found
    if ( "$arg:h" != "$arg:t" ) then            # head != tail, don't search
        if ( -e $arg ) then                     # just do simple lookup
            echo $arg
        else
            echo $arg not found
        endif
        continue
    else
        foreach i ( $path )
            if ( -x $i/$arg && ! -d $i/$arg ) then
                echo $i/$arg
                set found
                break
            endif
        end
    endif
    if ( ! $?found ) then
        echo no $arg in $path
    endif
end
/*--------------------------------------------------------------------------*/Jörg

 EMail:[EMAIL PROTECTED] (home) Jörg Schilling D-13353 Berlin
       [EMAIL PROTECTED]               (uni)  If you don't have iso-8859-1
       [EMAIL PROTECTED]           (work) chars I am J"org Schilling
 URL:  http://www.fokus.gmd.de/usr/schilling   ftp://ftp.fokus.gmd.de/pub/unix


--  
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to