Bug 1998 - `which' behaves different than the regular shell search
`which' behaves different than the regular shell search
Status: CLOSED CURRENTRELEASE
Product: Red Hat Linux
Classification: Retired
Component: which (Show other bugs)
6.0
All Linux
medium Severity medium
: ---
: ---
Assigned To: David Lawrence
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 1999-04-05 10:38 EDT by carlo
Modified: 2008-05-01 11:37 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 1999-04-06 12:31:01 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description carlo 1999-04-05 10:38:43 EDT
The current which is a hack (look a the source).
It's main problem is that it returns directories
as if these are executable (because the execute mode bit
is set).  This gives problems in some cases and is
inconsistent with the documentation.

I am willing to rewrite `which', let me know where
to send the new tar.gz and rpm etc.

--
From current discussion with config.guess author:

Ben Elliston (bje@cygnus.com) wrote:
| > From: Carlo Wood <carlo@runaway.xs4all.nl>
| > Message-Id: <199903091509.QAA03972@jolan.ppro>
| > Subject: binutils bug: config.guess
|
| > when trying to compile binutils-2.9.1.0.22b, I ran
| > into a problem with config.guess.
| > I have "." in my PATH, and it seems that makes
| > config.guess fail to execute `ld'. It tries to execute
| > the directory ld/ in binutils.
| > I know I shouldn't have a "." in my path before
| > /usr/bin, but I am sure I am not the only one that
| > has it any way :).
|
| This is quite a specific case that causes this to fail.
| Since it only occurs when there is a subdirectory named
| `ld' (as there is in binutils) and then only when you
| have `.' in front of the path to your ld program, I
| am inclined to suggest a binutils-only modification to
| config.guess that just warns:
|
|       if test -d `which ld`
|         echo "Error: cannot invoke ld"
|       fi

It is actually a bug in `which' anyway.
The documentation of `which' claims:

       Which  takes a series of program names, and prints
       out the full pathname of the program that the shell
       would call to execute it. It does this by simulating
       the shells searching of the $PATH environment
       variable.

But this is not correct in this case:

>mkdir ld
>which ld
./ld
>ld -V
GNU ld version 2.9.1 (with BFD 2.9.1.0.15)
  Supported emulations:
   elf_i386
   i386linux


`which' should skip anything that is not executable
and continue the search.  If fails to do that for
directories (maybe it only looks at the mode?).

I am going to write a new which that fixes that :/

--
 Carlo Wood  <carlo@runaway.xs4all.nl>
Comment 1 Jeff Johnson 1999-04-05 10:51:59 EDT
You can mail to me. Thanks for the report.
Comment 2 carlo 1999-04-06 12:01:59 EDT
Ok, I rewrote which.  Please get it from
http://www.xs4all.nl/~carlo17/which/
if there are problems let me know.

The tar contains a working which-2.0.spec file.
I'll leave it to you create the rpms.

Please make sure to remove the alias for which in
 /etc/bashrc when you add it to the new RedHat release.

Thanks, Carlo.
Comment 3 Preston Brown 1999-04-06 12:30:59 EDT
Carlo:

I have added your wish to the distribution.  Thank you very much for
your contribution.

------- Email Received From  Carlo Wood <carlo@runaway.xs4all.nl> 05/20/99 06:12 -------

Note You need to log in before you can comment on or make changes to this bug.