This service will be undergoing maintenance at 00:00 UTC, 2016-09-28. It is expected to last about 1 hours
Bug 3300 - which is which. Unpredictable.
which is which. Unpredictable.
Status: CLOSED NEXTRELEASE
Product: Red Hat Linux
Classification: Retired
Component: which (Show other bugs)
6.0
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Ngo Than
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 1999-06-06 10:44 EDT by torben
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-08-31 13:33:03 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)

  None (edit)
Description torben 1999-06-06 10:44:25 EDT
The `which' command should be quiet when finding nothing.

Which is also defined as a shell alias for type -path in
/etc/bashrc, so the behaviour can be quite unpredictable,
because the shell alias version IS quiet as it should be.
which-1.0-11 is not.

Examples, where the file foobar does not exist:

The shell version:
$ /bin/rm `which foobar`
rm: too few arguments
Try `rm --help' for more information.

The external version!!!:
$ su somebody # or bash
$ /bin/rm `which foobar`
rm: cannot remove `/usr/bin/which:': No such file or
directory
rm: cannot remove `no': No such file or directory
rm: cannot remove `foobar': No such file or directory
rm: cannot remove `in': No such file or directory
rm: cannot remove
`(/usr/local/bin:/usr/bin:/usr/local/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/usr/local/bin:/usr/X11R6/bin:/usr/local/bin)':
No such file or directory.

Suggested fix:
Remove the which binary and the /etc/bashrc alias and
create a scripts, /usr/bin/which, which says:
#!/bin/bash
type -path "$@"
Comment 1 David Lawrence 1999-06-07 18:37:59 EDT
I have verified these to occur in a stock install of Red Hat 6.0.
Comment 2 carlo 1999-08-28 10:01:59 EDT
This is also fixed as of which-2.x. Version 2 writes to stderr:

~>/bin/rm `which foobar`
/usr/bin/which: no foobar in
(.:~/bin:/usr/local/bin:/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/X11R6/bin:/usr/X11R6/bin:/opt/kde/bin:/usr/local/share/prototype/scripts:/usr/local/java/bin)
/bin/rm: too few arguments
Try `/bin/rm --help' for more information.
Comment 3 Bill Nottingham 1999-08-31 13:33:59 EDT
which-2.8 is in Raw Hide.

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