Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-3-0]: src/usr.bin/whereis Pull up following revision(s) (requeste...



details:   https://anonhg.NetBSD.org/src/rev/0f2731ffad3d
branches:  netbsd-3-0
changeset: 579271:0f2731ffad3d
user:      tron <tron%NetBSD.org@localhost>
date:      Thu Aug 10 12:11:59 2006 +0000

description:
Pull up following revision(s) (requested by cube in ticket #1456):
        usr.bin/whereis/whereis.c: revision 1.18
Apply patch from Michael van Elst to fix PR bin/34114:
which doesn't handle commands given as absolute pathnames.

diffstat:

 usr.bin/whereis/whereis.c |  17 ++++++++++++++---
 1 files changed, 14 insertions(+), 3 deletions(-)

diffs (38 lines):

diff -r 203ff54af122 -r 0f2731ffad3d usr.bin/whereis/whereis.c
--- a/usr.bin/whereis/whereis.c Sun Aug 06 11:48:42 2006 +0000
+++ b/usr.bin/whereis/whereis.c Thu Aug 10 12:11:59 2006 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: whereis.c,v 1.17 2004/05/23 02:24:06 christos Exp $    */
+/*     $NetBSD: whereis.c,v 1.17.4.1 2006/08/10 12:11:59 tron Exp $    */
 
 /*-
  * Copyright (c) 1993
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = "@(#)whereis.c  8.3 (Berkeley) 5/4/95";
 #endif
-__RCSID("$NetBSD: whereis.c,v 1.17 2004/05/23 02:24:06 christos Exp $");
+__RCSID("$NetBSD: whereis.c,v 1.17.4.1 2006/08/10 12:11:59 tron Exp $");
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -112,7 +112,18 @@
 
        /* For each path, for each program... */
        for (; *argv; ++argv)
-               for (p = std; p; p && (*p++ = ':')) {
+               if (**argv == '/') {
+                       if (stat(*argv, &sb) == -1)
+                               continue;
+                       if (!S_ISREG(sb.st_mode))
+                               continue;
+                       if (access(*argv, X_OK) == -1)
+                               continue;
+                       (void)printf("%s\n", *argv);
+                       found++;
+                       if (which)
+                               break;
+               } else for (p = std; p; p && (*p++ = ':')) {
                        t = p;
                        if ((p = strchr(p, ':')) != NULL) {
                                *p = '\0';



Home | Main Index | Thread Index | Old Index