From 858a4a945651c9c1ebc011c5cdfc1789acce3279 Mon Sep 17 00:00:00 2001 From: guamss Date: Thu, 29 Jun 2023 17:11:24 +0200 Subject: [PATCH] =?UTF-8?q?(feat):=20plus=20beau=20=E2=9D=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/input/input.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/input/input.c b/src/input/input.c index eb08f7b..23a617b 100644 --- a/src/input/input.c +++ b/src/input/input.c @@ -37,12 +37,24 @@ static char* get_prompt(lst** env) strcpy(cwd, "~"); strcat(cwd, cwd + strlen(home)); } - size = snprintf(NULL, 0, "%s@%s>%s $ ",user, hostname_buff, cwd) + 10; - out = malloc(size*sizeof(char)); - if(out == NULL) - return NULL; - sprintf(out, "%s@%s > %s $ ",user, hostname_buff, cwd); - return out; + if (strcmp(user, "root") == 0) + { + size = snprintf(NULL, 0, "[%s@%s] > %s # ",user, hostname_buff, cwd) + 10; + out = malloc(size*sizeof(char)); + if(out == NULL) + return NULL; + sprintf(out, "[%s@%s] > %s # ",user, hostname_buff, cwd); + return out; + } + else + { + size = snprintf(NULL, 0, "[%s@%s] >%s $ ",user, hostname_buff, cwd) + 10; + out = malloc(size*sizeof(char)); + if(out == NULL) + return NULL; + sprintf(out, "[%s@%s] > %s $ ",user, hostname_buff, cwd); + return out; + } } char *get_user_input(lst** env)