From f83a309e7fab99239b90ea149c714bc235da4897 Mon Sep 17 00:00:00 2001 From: czjstmax Date: Sat, 11 Apr 2026 20:23:54 +0200 Subject: 100 lines. precise. Signed-off-by: czjstmax --- nosh.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/nosh.c b/nosh.c index 0db35df..46e03b3 100644 --- a/nosh.c +++ b/nosh.c @@ -1,5 +1,5 @@ /* nosh - noshell - * ~100+ lines of pure POSIX and standard C code for thy eyes! + * 100 lines of pure POSIX and standard C code for thy eyes! * * von czjstmax, */ @@ -22,7 +22,7 @@ wordexp_t p; int main(void) { signal(SIGINT, handlecc); - + while (true) { printf("$ "); getline(&line, &len, stdin); @@ -31,11 +31,6 @@ int main(void) wordexp(line, &p, 0); - // debug -// for (size_t i = 0; i < p.we_wordc; i++) { -// printf("argv[%zu] = %s\n", i, p.we_wordv[i]); -// } - if (strlen(line) == 0) { wordfree(&p); continue; //otherwise.. SIGSEGV @@ -81,6 +76,7 @@ int main(void) else { pid_t pid = fork(); char **argv = p.we_wordv; // pray with me now + if (pid == 0) { execvp(p.we_wordv[0], argv); perror("nsh! ERROR: failed to execvp()"); @@ -99,7 +95,6 @@ int main(void) void handlecc(int sig) { - printf("\nnsh! %d caught.\nfreeing stuff before quitting.\n", sig); - exit(0); + (void)sig; } -- cgit v1.3.1