summaryrefslogtreecommitdiffstats
path: root/src/m_prompt.c
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-09-11 15:05:31 +0200
committerJozanLeClerc <bousset.rudy@gmail.com>2020-09-11 15:05:31 +0200
commit6f756ee6112c723cfe0f8ece2d530b249aa47e00 (patch)
treed855b1f53369b382c6cb204a3241561e48d99e5d /src/m_prompt.c
parentLOT to fix (diff)
download42-minishell-6f756ee6112c723cfe0f8ece2d530b249aa47e00.tar.gz
42-minishell-6f756ee6112c723cfe0f8ece2d530b249aa47e00.tar.bz2
42-minishell-6f756ee6112c723cfe0f8ece2d530b249aa47e00.tar.xz
42-minishell-6f756ee6112c723cfe0f8ece2d530b249aa47e00.tar.zst
42-minishell-6f756ee6112c723cfe0f8ece2d530b249aa47e00.zip
Fix
Diffstat (limited to 'src/m_prompt.c')
-rw-r--r--src/m_prompt.c14
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';