changeset 365:f9ec1fd54034

Correct log message, check last $PATH element properly, and set argv[0] to path being run and not just command name.
author Rob Landley <rob@landley.net>
date Sun, 13 Jul 2008 07:57:49 -0500
parents a9dfcdc8de35
children 03d1f75d2059
files sources/toys/wrappy.c
diffstat 1 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/sources/toys/wrappy.c	Sat Jul 12 00:36:50 2008 -0500
+++ b/sources/toys/wrappy.c	Sun Jul 13 07:57:49 2008 -0500
@@ -81,18 +81,21 @@
 
   // Hand off control to the real executable
 
-  for (p = p3 = realpath; *p3; p3++) {
+  for (p = p3 = realpath; ; p3++) {
     if (*p3==':' || !*p3) {
       char snapshot = *p3;
+      
       *p3 = 0;
       snprintf(blah, sizeof(blah)-1, "%s/%s", p, p2);
       *p3 = snapshot;
+      argv[0]=blah;
       execve(blah, argv, env);
+      if (!*p3) break;
       p = p3+1;
     }
   }
 
   // Should never happen, means environment setup is wrong.
-  fprintf(stderr, "Didn't find %s\n", logpath);
+  fprintf(stderr, "Didn't find %s\n", p2);
   exit(1);
 }