diff --git a/shell2 b/shell2 index a5a922f..155bb78 100755 Binary files a/shell2 and b/shell2 differ diff --git a/shell2.c b/shell2.c index 5fa923e..720743b 100644 --- a/shell2.c +++ b/shell2.c @@ -1,15 +1,56 @@ -#include +#include +#include +#include +#include +#include +#include +#include #define clear() printf("\033[H\033[J") void init_shell() { clear(); - printf("\n\n\n\n******************" - "************************"); + + printf("\n\n\n\n******************************************"); printf("\n\n\n\t****MY SHELL****"); printf("\n\n\t-USE AT YOUR OWN RISK-"); - printf("\n\n\n\n*******************" - "***********************"); + printf("\n\n\n******************************************"); + + char* username = getenv("USER"); + printf("\n\nUSER is: @%s\n", username); + sleep(1); + + clear(); +} + +int take_input(char* str) { + char* buf; + + buf = readline("\n>>> "); + if(strlen(buf) != 0) { + add_history(buf); + strcpy(str, buf); + return 0; + } else { + return 1; + } +} + +void print_dir() { + char cwd[1024]; + getcwd(cwd, sizeof(cwd)); + printf("\nDir: %s", cwd); +} + +def execute(char** parsed) { + pid_t pid = fork(); + + if (pid == -1) { + printf("\nFailed forking child.."); + return; + } else if (pid == 0) { + + } } int main() {