Bug 3300

Summary: which is which. Unpredictable.
Product: [Retired] Red Hat Linux Reporter: torben
Component: whichAssignee: Than Ngo <than>
Status: CLOSED NEXTRELEASE QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 6.0   
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 1999-08-31 17:33:03 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

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.