|
|
@ -6,7 +6,7 @@ |
|
|
|
/* By: mea <mea@student.42.fr> +#+ +:+ +#+ */ |
|
|
|
/* +#+#+#+#+#+ +#+ */ |
|
|
|
/* Created: 2022/01/06 09:02:57 by narnaud #+# #+# */ |
|
|
|
/* Updated: 2022/05/18 16:26:51 by narnaud@stude ### ########.fr */ |
|
|
|
/* Updated: 2022/05/27 08:46:51 by narnaud ### ########.fr */ |
|
|
|
/* */ |
|
|
|
/* ************************************************************************** */ |
|
|
|
|
|
|
@ -79,15 +79,15 @@ int ft_cd(t_datas *datas, t_command *cmd) |
|
|
|
char *home; |
|
|
|
|
|
|
|
if (cmd->argc > 2) |
|
|
|
return (cmd_error("cd", "too many arguments")); |
|
|
|
return (cmd_error("cd", "too many arguments\n", NULL)); |
|
|
|
if (cmd->argv[1]) |
|
|
|
{ |
|
|
|
if (access(cmd->argv[1], X_OK)) |
|
|
|
return (file_error(cmd->argv[0], cmd->argv[1], |
|
|
|
"Permission denied\n")); |
|
|
|
return (cmd_error(cmd->argv[0], cmd->argv[1], |
|
|
|
": Permission denied\n")); |
|
|
|
else if (access(cmd->argv[1], F_OK)) |
|
|
|
return (file_error(cmd->argv[0], cmd->argv[1], |
|
|
|
"Not a directory\n")); |
|
|
|
return (cmd_error(cmd->argv[0], cmd->argv[1], |
|
|
|
": Not a directory\n")); |
|
|
|
chdir(cmd->argv[1]); |
|
|
|
return (0); |
|
|
|
} |
|
|
@ -97,7 +97,7 @@ int ft_cd(t_datas *datas, t_command *cmd) |
|
|
|
if (*home) |
|
|
|
chdir(home); |
|
|
|
else |
|
|
|
return (cmd_error("cd", "HOME not set")); |
|
|
|
return (cmd_error("cd", "HOME not set\n", NULL)); |
|
|
|
} |
|
|
|
return (0); |
|
|
|
} |
|
|
@ -110,11 +110,11 @@ int ft_exit(t_datas *datas, t_command *cmd) |
|
|
|
{ |
|
|
|
if (!ft_isnumber(cmd->argv[1])) |
|
|
|
{ |
|
|
|
cmd_error("exit", "numeric argument required"); |
|
|
|
cmd_error("exit", "numeric argument required\n", NULL); |
|
|
|
halt(datas, 2, 0); |
|
|
|
} |
|
|
|
halt(datas, ft_atoi(cmd->argv[1]) % 255, 0); |
|
|
|
} |
|
|
|
cmd_error("exit", "too many arguments"); |
|
|
|
cmd_error("exit", "too many arguments\n", NULL); |
|
|
|
return (EXIT_FAILURE); |
|
|
|
} |
|
|
|