diff options
| author | iceyrazor <iceyrazor@mailfence.com> | 2026-02-09 19:36:03 -0600 |
|---|---|---|
| committer | iceyrazor <iceyrazor@mailfence.com> | 2026-02-09 19:36:03 -0600 |
| commit | f1f01cbbf9681ee311a69db40e832c630950cb53 (patch) | |
| tree | c2f1f743856ec7601635e74b0bdd5d1f633c80ae /src/main.c | |
| parent | 5f08fd6e7794dcdfb74c93af16dfbc903458b0ea (diff) | |
environment vairables. set and get
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; } |
