diff options
Diffstat (limited to 'src/main.c')
| -rwxr-xr-x | src/main.c | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -1,7 +1,5 @@ #include <stdio.h> #include <stdlib.h> -#include <string.h> -#include <sys/wait.h> #include <unistd.h> #include "lsh_main_func.c" @@ -30,15 +28,17 @@ void lsh_loop(SHELL_OB *shell_obj) int main(int argc, char **argv){ SHELL_OB shell_obj; + shell_obj.prompt = (char *)malloc(sizeof(char) * 1024); //get the hostname char *hostname = (char *)malloc(sizeof(char) * 1024); gethostname(hostname,sizeof(char) * 1024); - shell_obj.prompt=strcat(strcat(strcat(getenv("USER"), "@"), (char *)hostname), "> "); + snprintf(shell_obj.prompt,sizeof(char) * 1024,"%s@%s> ",getenv("USER"),hostname); lsh_loop(&shell_obj); free(hostname); + free(shell_obj.prompt); return EXIT_SUCCESS; } |
