From 0cb189892af7d2b5274a53849161986f8956b71c Mon Sep 17 00:00:00 2001 From: stitchy Date: Thu, 8 Feb 2024 05:40:49 +0000 Subject: [PATCH] Add nixos support --- smallsh/main.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/smallsh/main.c b/smallsh/main.c index d7a8118..22796a0 100644 --- a/smallsh/main.c +++ b/smallsh/main.c @@ -100,12 +100,6 @@ void inbuilt_cd(char* args) { int run_command(char*** array, int num_array) { - // Point all executables to /usr/bin (bad Idea but it works) - char* comb_string = malloc(sizeof(char) * 100); - sprintf(comb_string, "/usr/bin/"); - strcat(comb_string, (*array)[0]); - - //Check to see if the process is ran in the background int background = 0; if(!strncmp("&", (*array)[num_array - 1], 1)) { @@ -191,10 +185,10 @@ int run_command(char*** array, int num_array) { } // Spawn new Process - pid = execv(comb_string, (*array)); + pid = execvp((*array)[0], (*array)); // Handle error on spawning process - perror(comb_string); + perror((*array)[0]); exit(1); } @@ -208,8 +202,6 @@ int run_command(char*** array, int num_array) { if(!background) waitpid(f, &status, 0); - free(comb_string); - return status; }