Bug 3300 - which is which. Unpredictable.
Summary: which is which. Unpredictable.
Keywords:
Status: CLOSED NEXTRELEASE
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: which
Version: 6.0
Hardware: i386
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Than Ngo
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 1999-06-06 14:44 UTC by torben
Modified: 2008-05-01 15:37 UTC (History)
0 users

Fixed In Version:
Clone Of:
Environment:
Last Closed: 1999-08-31 17:33:03 UTC
Embargoed:


Attachments (Terms of Use)

Description torben 1999-06-06 14:44:25 UTC
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 22:37:59 UTC
I have verified these to occur in a stock install of Red Hat 6.0.

Comment 2 carlo 1999-08-28 14:01:59 UTC
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 17:33:59 UTC
which-2.8 is in Raw Hide.


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