diff options
-rw-r--r-- | sh/parser.c | 9 | ||||
-rw-r--r-- | sh/sh.c | 3 |
2 files changed, 6 insertions, 6 deletions
diff --git a/sh/parser.c b/sh/parser.c index 47edef2..c5562d7 100644 --- a/sh/parser.c +++ b/sh/parser.c @@ -63,15 +63,16 @@ int parseCommand(int argc, char *argv[]) { */ status_code = execvp(argv[0], argv); /* If the child process is still alive, we know execvp(3) failed. */ - exit(errno); + exit(-errno); } /* This code may be used to store the exit value in $?. */ //if (errno != EINTR && WEXITSTATUS(status_code) !=) return WEXITSTATUS(status_code); //else return 0; err = WEXITSTATUS(status_code); - if (err == E2BIG || err == EACCES || err == EINVAL || err == ELOOP || - err == ENAMETOOLONG || err == ENOENT || err == ENOTDIR) - printf("sh: %s: %s", argv[0], strerror(err)); + if (err-256 == -E2BIG || err-256 == -EACCES || err-256 == -EINVAL || + err-256 == -ELOOP || + err-256 == -ENAMETOOLONG || err-256 == -ENOENT || err-256 == -ENOTDIR) + printf("sh: %s: %s\n", argv[0], strerror(-(err-256))); return err; } @@ -134,8 +134,7 @@ void commandLoop(FILE *filstr) { } else { command_argc = splitCommand(name, command); /* See parser.c */ - if ((errno = parseCommand(command_argc, command)) != 0 /* See parser.c */ ) - printf("sh: %s: %s\n", command[0], strerror(errno)); + parseCommand(command_argc, command); /* See parser.c */ } } } |