[BACK]Return to which.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / which

Diff for /src/usr.bin/which/which.c between version 1.11 and 1.12

version 1.11, 2003/06/17 21:56:26 version 1.12, 2004/09/23 17:44:47
Line 38 
Line 38 
 extern char *__progname;  extern char *__progname;
   
 int findprog(char *, char *, int, int);  int findprog(char *, char *, int, int);
 void usage(void);  __dead void usage(void);
   
 /*  /*
  * which(1) -- find an executable(s) in the user's path   * which(1) -- find an executable(s) in the user's path
Line 121 
Line 121 
                 if ((stat(prog, &sbuf) == 0) && S_ISREG(sbuf.st_mode) &&                  if ((stat(prog, &sbuf) == 0) && S_ISREG(sbuf.st_mode) &&
                     access(prog, X_OK) == 0) {                      access(prog, X_OK) == 0) {
                         (void)puts(prog);                          (void)puts(prog);
                         return(1);                          return (1);
                 } else {                  } else {
                         (void)printf("%s: Command not found.\n", prog);                          (void)printf("%s: Command not found.\n", prog);
                         return(0);                          return (0);
                 }                  }
         }          }
   
Line 142 
Line 142 
   
                 if (plen + 1 + proglen >= sizeof(filename)) {                  if (plen + 1 + proglen >= sizeof(filename)) {
                         warnx("%s/%s: %s", p, prog, strerror(ENAMETOOLONG));                          warnx("%s/%s: %s", p, prog, strerror(ENAMETOOLONG));
                         return(0);                          free(path);
                           return (0);
                 }                  }
   
                 snprintf(filename, sizeof(filename), "%s/%s", p, prog);                  snprintf(filename, sizeof(filename), "%s/%s", p, prog);
Line 150 
Line 151 
                     access(filename, X_OK) == 0) {                      access(filename, X_OK) == 0) {
                         (void)puts(filename);                          (void)puts(filename);
                         rval = 1;                          rval = 1;
                         if (!allmatches)                          if (!allmatches) {
                                 return(rval);                                  free(path);
                                   return (rval);
                           }
                 }                  }
         }          }
         (void)free(path);          (void)free(path);
Line 159 
Line 162 
         /* whereis(1) is silent on failure. */          /* whereis(1) is silent on failure. */
         if (!rval && progmode != PROG_WHEREIS)          if (!rval && progmode != PROG_WHEREIS)
                 (void)printf("%s: Command not found.\n", prog);                  (void)printf("%s: Command not found.\n", prog);
         return(rval);          return (rval);
 }  }
   
 void  __dead void
 usage(void)  usage(void)
 {  {
         (void) fprintf(stderr, "Usage: %s [-a] name [...]\n", __progname);          (void) fprintf(stderr, "Usage: %s [-a] name [...]\n", __progname);

Legend:
Removed from v.1.11  
changed lines
  Added in v.1.12