diff options
Diffstat (limited to 'src/m_prompt.c')
-rw-r--r-- | src/m_prompt.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/m_prompt.c b/src/m_prompt.c index ff491c8..584a98d 100644 --- a/src/m_prompt.c +++ b/src/m_prompt.c @@ -34,14 +34,20 @@ static char { if (var[i + 1] == '0' && var[i + 2] == '3' && var[i + 3] == '3') { - (void)ft_memmove(var + i, var + i + 3, ft_strlen(var + i + 3) + 1); + (void)ft_memmove(var + i, var + (i + 3), (ft_strlen(var + (i + 3)) + 1) * sizeof(char)); var[i] = C_ESC; } else if (var[i + 1] == 'n') { - (void)ft_memmove(var + i, var + i + 1, ft_strlen(var + i + 1) + 1); + (void)ft_memmove(var + i, var + (i + 1), (ft_strlen(var + (i + 1)) + 1) * sizeof(char)); var[i] = C_LF; } + else if (var[i + 1] == 'h' || var[i + 1] == 'H') + { + gethostname(tmp, 255); + (void)ft_memmove(var + i + ft_strlen(tmp), var + (i + 2), (ft_strlen(var + (i + 2)) + 1) * sizeof(char)); + (void)ft_memcpy(var + i, tmp, ft_strlen(tmp) * sizeof(char)); + } else if (var[i + 1] == 'w') { u_get_var_value(tmp, "$PWD", PATH_MAX, msh); @@ -82,11 +88,11 @@ static char static void m_update_psx(uint8_t x, t_msh *msh) { - char var[2048]; + char var[ARG_MAX]; char psx[5]; ft_sprintf(psx, "$PS%hhu", x); - u_get_var_value(var, psx, 2048, msh); + u_get_var_value(var, psx, ARG_MAX, msh); if (var[0] == C_NUL) { msh->ps[x - 1][0] = '\0'; |