cd refactoring, error_wrappers

This commit is contained in:
LuckyLaszlo
2021-12-05 16:28:41 +01:00
parent c3a9035622
commit 66183ab441
4 changed files with 16 additions and 21 deletions

View File

@@ -6,7 +6,7 @@
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/12/04 19:31:19 by lperrey #+# #+# */
/* Updated: 2021/12/04 20:01:37 by lperrey ### ########.fr */
/* Updated: 2021/12/05 16:21:41 by lperrey ### ########.fr */
/* */
/* ************************************************************************** */
@@ -22,21 +22,12 @@ int builtin_cd(int argc, char *argv[], t_all *c)
{
tmp = getenv("HOME");
if (!tmp)
{
shell_error("cd: ", "HOME not set");
return (EXIT_FAILURE);
}
return (shell_error("cd: ", "HOME not set", "", EXIT_FAILURE));
}
else if (argc > 2)
{
shell_error("cd: ", "too many arguments");
return (EXIT_FAILURE);
}
return (shell_error("cd: ", "too many arguments", "", EXIT_FAILURE));
if (chdir(tmp) == -1)
{
shell_perror("cd: ", tmp, ": ");
return (EXIT_FAILURE);
}
return (shell_perror("cd: ", tmp, ": ", EXIT_FAILURE));
tmp = init_prompt(c->prompt_base);
if (!tmp)
return (ft_reti_perror(EXIT_FAILURE, "builtin_cd, init_prompt()"));