Matrix's behavior is less stupid
authorAndrew Waterman <waterman@ubuntu.(none)>
Mon, 11 Jan 2010 05:53:12 +0000 (21:53 -0800)
committerAndrew Waterman <waterman@ubuntu.(none)>
Mon, 11 Jan 2010 05:53:12 +0000 (21:53 -0800)
If you hit enter, it doesn't try to execute the current directory :-)

user/apps/parlib/matrix.c
user/apps/parlib/run_binary.c

index 701268b..a38a35e 100644 (file)
@@ -53,7 +53,7 @@ int main(int argc, char** argv)
        while(1) {
                char* s = readline(prompt);
 
-               if (s == NULL)
+               if (!s || !*s)
                        continue;
 
                if(strcmp(s, "draw_nanwan") == 0)
index 1f8a0ad..8d4c6d7 100644 (file)
@@ -47,8 +47,11 @@ int shell_exec(const char* cmdline)
                }
 
                char* fn = NULL, *buf = NULL;
-               if(argv[0][0] == '/')
-                       fn = argv[0];
+               if(strchr(argv[0],'/'))
+               {
+                       if(access(argv[0],X_OK) == 0)
+                               fn = argv[0];
+               }
                else
                {
                        buf = (char*)malloc(sizeof(char)*(strlen(argv[0])+strlen(path)+2));
@@ -67,12 +70,12 @@ int shell_exec(const char* cmdline)
                                        break;
                                path = end+1;
                        }
+               }
 
-                       if(fn == NULL)
-                       {
-                               printf("%s: not found\n",argv[0]);
-                               exit(1);
-                       }
+               if(fn == NULL)
+               {
+                       printf("%s: not found\n",argv[0]);
+                       exit(1);
                }
 
                execve(fn,argv,envp);