init_prompt() correct error return
This commit is contained in:
16
srcs/init.c
16
srcs/init.c
@@ -50,7 +50,7 @@ char **retrieve_path(void)
|
||||
return (path_split);
|
||||
}
|
||||
|
||||
static char *init_prompt_base(void) // WIP, error return TODO
|
||||
static char *init_prompt_base(void)
|
||||
{
|
||||
char *prompt_base;
|
||||
char *tmp;
|
||||
@@ -61,21 +61,33 @@ static char *init_prompt_base(void) // WIP, error return TODO
|
||||
if (!tmp)
|
||||
tmp = U_DEFAULT_USER;
|
||||
prompt_base = ft_strjoin(TERM_LIGHT_GREEN, tmp);
|
||||
if (!prompt_base)
|
||||
return (NULL);
|
||||
prompt_base = ft_strjoinfree_s1(prompt_base, "@");
|
||||
if (!prompt_base)
|
||||
return (NULL);
|
||||
tmp = getenv("NAME");
|
||||
if (!tmp)
|
||||
tmp = U_DEFAULT_NAME;
|
||||
prompt_base = ft_strjoinfree_s1(prompt_base, tmp);
|
||||
if (!prompt_base)
|
||||
return (NULL);
|
||||
prompt_base = ft_strjoinfree_s1(prompt_base, TERM_RESET":"TERM_LIGHT_BLUE);
|
||||
if (!prompt_base)
|
||||
return (NULL);
|
||||
return (prompt_base);
|
||||
}
|
||||
|
||||
char *init_prompt(char *prompt_base) // WIP, error return TODO
|
||||
char *init_prompt(char *prompt_base)
|
||||
{
|
||||
char *prompt;
|
||||
|
||||
prompt = ft_strjoinfree_s2(prompt_base, getcwd(NULL, 0));
|
||||
if (!prompt)
|
||||
return (NULL);
|
||||
prompt = ft_strjoinfree_s1(prompt, TERM_RESET U_PROMPT_END);
|
||||
if (!prompt)
|
||||
return (NULL);
|
||||
return (prompt);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user