This commit is contained in:
benstrb 2025-10-12 22:06:14 +02:00
parent c6cab81a01
commit 5120f27b59
2 changed files with 34 additions and 17 deletions

BIN
shell2

Binary file not shown.

View file

@ -1,10 +1,11 @@
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <readline/readline.h>
#include <unistd.h>
#include <sys/wait.h>
#include <readline/history.h>
#include <readline/readline.h>
#define clear() printf("\033[H\033[J")
@ -42,15 +43,31 @@ void print_dir() {
printf("\nDir: %s", cwd);
}
def execute(char** parsed) {
void execute_args(char **parsed) {
pid_t pid = fork();
if (pid == -1) {
printf("\nFailed forking child..");
return;
} else if (pid == 0) {
if (execvp(parsed[0], parsed) < 0) {
printf("\nCould not execute command..");
}
exit(0);
} else {
wait(NULL);
return;
}
}
void open_help() {
puts("\n***Welcome to my shell help"
"\n-Use the shell at your own risk..."
"\nList of commands support:"
"\n>cd"
"\n>ls"
"\n>exit"
"\n>all other general commands available in UNIX shell");
}
int main() {