summaryrefslogtreecommitdiffstats
path: root/src/b_cd.c
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-08-24 19:51:45 +0200
committerJozanLeClerc <bousset.rudy@gmail.com>2020-08-24 19:51:45 +0200
commitd2570eca22dc09dab77930c2a4de3ba9ebcbcdab (patch)
tree954724f58451f7572ff727818876c17eab10d394 /src/b_cd.c
parentFreed leaks, fix in progress (diff)
download42-minishell-d2570eca22dc09dab77930c2a4de3ba9ebcbcdab.tar.gz
42-minishell-d2570eca22dc09dab77930c2a4de3ba9ebcbcdab.tar.bz2
42-minishell-d2570eca22dc09dab77930c2a4de3ba9ebcbcdab.tar.xz
42-minishell-d2570eca22dc09dab77930c2a4de3ba9ebcbcdab.tar.zst
42-minishell-d2570eca22dc09dab77930c2a4de3ba9ebcbcdab.zip
pwd fix
Diffstat (limited to 'src/b_cd.c')
-rw-r--r--src/b_cd.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/b_cd.c b/src/b_cd.c
index daf839d..e322ef8 100644
--- a/src/b_cd.c
+++ b/src/b_cd.c
@@ -83,7 +83,7 @@ static void
}
else
{
- j = ft_strlen(repath) + 1;
+ j = (ft_strncmp(repath, "/", 2) == 0) ? (1) : (ft_strlen(repath) + 1);
repath[j - 1] = '/';
ft_strlcpy(repath + j, splited[i], ft_strlen(splited[i]) + 1);
}
@@ -113,7 +113,6 @@ static void
ft_delwords(splited);
}
repath[0] = (repath[0] == '\0') ? '/' : repath[0];
- ft_printf("[%s]\n", repath);
ft_sprintf(fmt, "%s=%s", "PWD", repath);
b_export_with_equals(fmt, msh);
ft_memdel((void*)&msh->cwd);
@@ -137,7 +136,8 @@ uint8_t
{
if ((path = u_get_var_value("$HOME", msh)) == NULL)
{
- ft_dprintf(STDERR_FILENO, "minishell: cd: %s\n", FT_FAIL_HOME_NOT_SET);
+ ft_dprintf(STDERR_FILENO, "minishell: cd: %s\n",
+ FT_FAIL_HOME_NOT_SET);
return (2);
}
}