summaryrefslogtreecommitdiff
path: root/nosh.c
diff options
context:
space:
mode:
authorczjstmax <jstmaxlol@disroot.org>2026-04-11 20:23:54 +0200
committerczjstmax <jstmaxlol@disroot.org>2026-04-11 20:23:54 +0200
commitf83a309e7fab99239b90ea149c714bc235da4897 (patch)
tree18ee2339f5099f11168a02c360e726141bef4752 /nosh.c
parent7b28c03528c1100729facbf6775493e1b531b574 (diff)
100 lines. precise.HEADmaster
Signed-off-by: czjstmax <jstmaxlol@disroot.org>
Diffstat (limited to 'nosh.c')
-rw-r--r--nosh.c13
1 files 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, <jstmaxlol at disroot dot org>
*/
@@ -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;
}