Search for proper executables, ignore directories

This commit is contained in:
helbig 1998-02-01 20:01:29 +00:00
parent 188cf22a57
commit 53c968c454

View File

@ -24,7 +24,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# $Id: which.pl,v 1.11 1997/08/26 11:13:39 charnier Exp $
# $Id: which.pl,v 1.12 1998/01/02 13:46:25 helbig Exp $
$all = $silent = $found = 0;
@path = split(/:/, $ENV{'PATH'});
@ -42,13 +42,13 @@ if ($ARGV[0] eq "-a") {
}
foreach $prog (@ARGV) {
if ("$prog" =~ '/' && -x "$prog") {
if ("$prog" =~ '/' && -x "$prog" && -f "$prog") {
print "$prog\n" unless $silent;
$found = 1;
} else {
foreach $e (@path) {
$e = "." if !$e;
if (-x "$e/$prog") {
if (-x "$e/$prog" && -f "$e/$prog") {
print "$e/$prog\n" unless $silent;
$found = 1;
last unless $all;