Created
September 22, 2011 17:56
-
-
Save gljeremy/1235482 to your computer and use it in GitHub Desktop.
which command for windows
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/perl | |
foreach my $arg (@ARGV) { | |
#print $arg, "\n"; | |
my $found = 0; | |
foreach my $dir (split(/\;/, $ENV{"PATH"})) { | |
foreach my $ext ('', split(/\;/, $ENV{"PATHEXT"})) { | |
$fqpath = $dir . "\\" . $arg . $ext; | |
#print $fqpath, "\n"; | |
if (-f $fqpath) { | |
print $fqpath, "\n"; | |
$found++; | |
last; | |
} | |
} | |
last if $found; | |
} | |
if (! $found) { | |
print $arg " not found in ", $ENV{"PATH"}, "\n"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment