matrix now sets up default PATH
authorAndrew Waterman <waterman@parcad.millennium.berkeley.edu>
Sat, 6 Feb 2010 23:35:54 +0000 (15:35 -0800)
committerAndrew Waterman <waterman@parcad.millennium.berkeley.edu>
Sat, 6 Feb 2010 23:35:54 +0000 (15:35 -0800)
user/apps/parlib/matrix.c
user/apps/parlib/run_binary.c

index a38a35e..2c8d5cb 100644 (file)
@@ -44,8 +44,21 @@ void date()
        puts(asctime(tt));
 }
 
+void setup_environ()
+{
+       static char* my_environ[] = {
+               "PATH=:/bin:/usr/bin",
+               "LD_LIBRARY_PATH=/lib:/usr/lib",
+               0
+       };
+
+       environ = my_environ;
+}
+
 int main(int argc, char** argv)
 {      
+       setup_environ();
+
        set_default_user();
        printf("Welcome to the Tessellation OS newlib test suite!\n");
        printf("Enter at your own risk....\n");
index 8d4c6d7..e46c4e6 100644 (file)
@@ -1,3 +1,4 @@
+#include <assert.h>
 #include <string.h>
 #include <stdlib.h>
 #include <sys/types.h>
@@ -35,16 +36,7 @@ int shell_exec(const char* cmdline)
                for(nenv = 0; environ[nenv]; nenv++)
                        if(strncmp(environ[nenv],"PATH=",5) == 0)
                                path = environ[nenv]+5;
-
-               if(path == NULL)
-               {
-                       envp = (char**)malloc(sizeof(char**)*(nenv+2));
-                       for(int i = 0; i < nenv; i++)
-                               envp[i] = environ[i];
-                       envp[nenv] = "PATH=:/bin:/usr/bin";
-                       path = envp[nenv]+5;
-                       envp[nenv+1] = 0;
-               }
+               assert(path);
 
                char* fn = NULL, *buf = NULL;
                if(strchr(argv[0],'/'))