mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
feat(builtins/cd): on error, print path
This commit is contained in:
parent
29bbb5e572
commit
9fcb34e1d5
2 changed files with 21 additions and 6 deletions
|
|
@ -3,10 +3,10 @@
|
|||
/* ::: :::::::: */
|
||||
/* builtin_cd.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: jguelen <jguelen@student.42.fr> +#+ +:+ +#+ */
|
||||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/03/31 16:20:17 by khais #+# #+# */
|
||||
/* Updated: 2025/04/07 17:35:16 by jguelen ### ########.fr */
|
||||
/* Updated: 2025/04/25 16:07:25 by khais ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -14,10 +14,12 @@
|
|||
#include "libft.h"
|
||||
#include <unistd.h>
|
||||
#include "../../env/env_manip.h"
|
||||
#include "../../ft_errno.h"
|
||||
#include <errno.h>
|
||||
|
||||
static void ft_chdir(char *path, t_minishell *app)
|
||||
{
|
||||
int saveerrno;
|
||||
|
||||
if (path[0] == '\0')
|
||||
app->last_return_value = 0;
|
||||
else if (chdir(path) == 0)
|
||||
|
|
@ -25,8 +27,9 @@ static void ft_chdir(char *path, t_minishell *app)
|
|||
else
|
||||
{
|
||||
app->last_return_value = 1;
|
||||
ft_errno(FT_EERRNO);
|
||||
ft_perror("minishell: cd");
|
||||
saveerrno = errno;
|
||||
ft_dprintf(STDERR_FILENO, "minishell: cd: %s: %s\n", path,
|
||||
strerror(saveerrno));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue