summaryrefslogtreecommitdiffstats
path: root/src/b_cd.c
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-08-10 17:56:38 +0200
committerJozanLeClerc <bousset.rudy@gmail.com>2020-08-10 17:56:38 +0200
commit4b233e06a16bf5183223e8253b4d9ac9ee59e6a2 (patch)
treedc36a64dcad37e076f478aadc7cccb0f322ea192 /src/b_cd.c
parentpwd TODO done (diff)
download42-minishell-4b233e06a16bf5183223e8253b4d9ac9ee59e6a2.tar.gz
42-minishell-4b233e06a16bf5183223e8253b4d9ac9ee59e6a2.tar.bz2
42-minishell-4b233e06a16bf5183223e8253b4d9ac9ee59e6a2.tar.xz
42-minishell-4b233e06a16bf5183223e8253b4d9ac9ee59e6a2.tar.zst
42-minishell-4b233e06a16bf5183223e8253b4d9ac9ee59e6a2.zip
Work in progress
Diffstat (limited to 'src/b_cd.c')
-rw-r--r--src/b_cd.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/b_cd.c b/src/b_cd.c
index 1af8104..9833172 100644
--- a/src/b_cd.c
+++ b/src/b_cd.c
@@ -30,16 +30,14 @@ static void
{
if (!(*path = ft_strdup(*args)))
{
- s_destroy(msh);
- f_fail_alloc(msh);
+ f_alloc_and_destroy_msh(msh);
}
if (!ft_strncmp("~/", *path, 2) || !ft_strncmp("~", *path, 2))
{
if (!(*path = ft_strsubst(*path,
"~", u_get_var_value("$HOME", msh))))
{
- s_destroy(msh);
- f_fail_alloc(msh);
+ f_alloc_and_destroy_msh(msh);
}
}
}
@@ -54,7 +52,7 @@ static void
if ((pwd = u_get_var_value("$PWD", msh)) == NULL)
{
if ((pwd = ft_strdup(msh->cwd)) == NULL)
- f_fail_alloc_and_destroy(msh);
+ f_alloc_and_destroy_msh(msh);
}
if ((tmp = u_get_var_value("$OLDPWD", msh)) == NULL)
{
@@ -114,7 +112,7 @@ static void
if (path[0] != '/')
ft_memcpy(repath, msh->cwd, ft_strlen(msh->cwd));
if ((splited = ft_split(path, '/')) == NULL)
- f_fail_alloc_and_destroy(msh);
+ f_alloc_and_destroy_msh(msh);
b_fill_repath(repath, splited);
repath[0] = (repath[0] == '\0') ? '/' : repath[0];
ft_delwords(splited);
@@ -127,7 +125,7 @@ static void
}
ft_memdel((void*)&msh->cwd);
if ((msh->cwd = ft_strdup(repath)) == NULL)
- f_fail_alloc_and_destroy(msh);
+ f_alloc_and_destroy_msh(msh);
}
uint8_t