From fa09f765823ca8bb85ce514876253d565f3c1b3a Mon Sep 17 00:00:00 2001 From: Kevin Lange Date: Tue, 6 Dec 2011 20:36:40 -0600 Subject: [PATCH] [esh] Handle bad execs --- userspace/esh.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/userspace/esh.c b/userspace/esh.c index c551d2a0..e9bc1094 100644 --- a/userspace/esh.c +++ b/userspace/esh.c @@ -23,7 +23,6 @@ int main(int argc, char ** argv) { fflush(stdout); fgets(cmd, 1024, stdin); cmd[strlen(cmd)-1] = '\0'; - printf("[%s]\n", cmd); char *p, *tokens[512], *last; int i = 0; for ((p = strtok_r(cmd, " ", &last)); p; @@ -31,18 +30,21 @@ int main(int argc, char ** argv) { if (i < 511) tokens[i] = p; } tokens[i] = NULL; - for (uint32_t j = 0; j < i; ++j) { - printf("> %s\n", tokens[j]); + if (!tokens[0] || strlen(tokens[0]) < 1) { + continue; } if (!strcmp(tokens[0],"exit")) { goto exit; } uint32_t f = fork(); if (getpid() != pid) { - printf("Executing %s!\n", tokens[0]); - execve(tokens[0], tokens, NULL); + int i = execve(tokens[0], tokens, NULL); + return i; } else { - syscall_wait(f); + int i = syscall_wait(f); + if (i) { + printf("[%d] "); + } } } exit: