which is not which

Voluspa voluspa at bigfoot.com
Sun Sep 8 11:31:30 PDT 2002

Don't know why, or how, but the "which" command in a LFS system (2001-11-19) gets converted to an internal bash command called "type":

loke:loke:~$ which --help
bash: type: illegal option: --
type: usage: type [-apt] name [name ...]

Ok, fine. But while "which ed" correctly points to /bin/ed, the following snippet fails miserably (picked from an install script for dri on ATI's mach64 - http://dri.sourceforge.net/snapshots/bleeding-edge/mach64-20020908-linux.i386.tar.bz2):

-- quote --

# [...]

# Check if ed is installed
which ed &> /dev/null
if [ "$?" != "0" ]; then
        echo "Could not located 'ed' editor. Aborting."
        exit 127;
-- unquote --

Removing the /dev/null part reveals that:

loke:loke:~$ ./snippet.bash 
./snippet.bash: which: command not found
Could not located 'ed' editor. Aborting.

So, GNU bash, version 2.05a.0(1) does not use the internal equiv of "which" if the command is executed from within a script. It's kind of unfortunate... I've also seen a bit of mess 'cos of this in the WineX install.

Which leads to ;-) please consider the inclusion of an external "which" program.

Mats Johannesson
Unsubscribe: send email to listar at linuxfromscratch.org
and put 'unsubscribe lfs-dev' in the subject header of the message

More information about the lfs-dev mailing list