summaryrefslogtreecommitdiffstats
path: root/usr.bin/which
diff options
context:
space:
mode:
authorhelbig <helbig@FreeBSD.org>1998-01-02 13:46:25 +0000
committerhelbig <helbig@FreeBSD.org>1998-01-02 13:46:25 +0000
commit197f0b69d78a1b5722ee9fea48afbe26936aa5f2 (patch)
treebaf4846256abc1fe539cc4cc75684fb2a056c7e6 /usr.bin/which
parentd9810a8a17267755df325deb0042a9901d97cae7 (diff)
downloadFreeBSD-src-197f0b69d78a1b5722ee9fea48afbe26936aa5f2.zip
FreeBSD-src-197f0b69d78a1b5722ee9fea48afbe26936aa5f2.tar.gz
Don't ignore empty components of $PATH, i. e. colon at the beginning,
the end or two successive colons. Reviewed and improved by wosch.
Diffstat (limited to 'usr.bin/which')
-rwxr-xr-xusr.bin/which/which.pl7
1 files changed, 6 insertions, 1 deletions
diff --git a/usr.bin/which/which.pl b/usr.bin/which/which.pl
index 2def134..688eb6a 100755
--- a/usr.bin/which/which.pl
+++ b/usr.bin/which/which.pl
@@ -24,10 +24,14 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $Id: which.pl,v 1.10 1997/02/22 19:57:51 peter Exp $
+# $Id: which.pl,v 1.11 1997/08/26 11:13:39 charnier Exp $
$all = $silent = $found = 0;
@path = split(/:/, $ENV{'PATH'});
+if ($ENV{'PATH'} =~ /:$/) {
+ $#path = $#path + 1;
+ $path[$#path] = "";
+}
if ($ARGV[0] eq "-a") {
$all = 1; shift @ARGV;
@@ -43,6 +47,7 @@ foreach $prog (@ARGV) {
$found = 1;
} else {
foreach $e (@path) {
+ $e = "." if !$e;
if (-x "$e/$prog") {
print "$e/$prog\n" unless $silent;
$found = 1;
OpenPOWER on IntegriCloud