Commit c7a95c02 authored by komask's avatar komask
Browse files

corrections on builtins

parent 1f591552
......@@ -33,7 +33,7 @@
# define FT_PS1 "$ "
# define BUILTINS "echo/cd/pwd/export/unset/env/exit"
# define BUILTINS "echo/cd/pwd/env/export/unset/exit"
# define SHLVL_STR "SHLVL"
......
......@@ -7,12 +7,6 @@ comportement simplifié ^D
masaki:
stat_loc pour
export fd = fd
unset fd = fd
(void)var; to keep?
M_ERROR on peut s'en passer?
a la fin avec rgrep:
......
......@@ -235,6 +235,11 @@ int ft_export(char **args, t_xe *xe)
ret = WRITE_ERR;
}
else
{
xe->stat_loc = 0;
ret = ft_export_checks(args + 1, xe);
if (ret != SUCCESS)
xe->stat_loc = 1;
}
return (ret);
}
......@@ -3,17 +3,19 @@
int ft_pwd(char **args, t_xe *xe)
{
char *buf;
int ret;
(void)args;
(void)xe;
ret = SUCCESS;
buf = getcwd(NULL, 0);
if (buf == NULL)
return (INVALID_PWD_PATH);
if (ft_putendl_fd(buf, STDOUT_FILENO) != WRITE_SUCCESS)
if (buf != NULL)
{
if (ft_putendl_fd(buf, STDOUT_FILENO) != WRITE_SUCCESS)
ret = WRITE_ERR;
free(buf);
return (WRITE_ERR);
}
free(buf);
return (SUCCESS);
else
ret = INVALID_PWD_PATH;
return (ret);
}
......@@ -30,6 +30,7 @@ static int unset_one_var(char *var, t_xe *xe)
int ft_unset(char **args, t_xe *xe)
{
args++;
xe->stat_loc = 0;
while (*args != NULL)
{
if (check_var_name(*args, ENTIRE_STR) == SUCCESS)
......
......@@ -231,8 +231,8 @@ int execute_cmd(char **args, char **redir_paths, enum e_redir_op *redir_types,
int i;
int ret;
enum e_cmd_code cmd_code;
const t_exec command[8] = {ft_echo, ft_cd, ft_pwd, ft_export, ft_unset,
ft_env, ft_exit, launch_ext};
const t_exec command[8] = {ft_echo, ft_cd, ft_pwd, ft_env, ft_export,
ft_unset, ft_exit, launch_ext};
i = 0;
if (redir_paths != NULL)
......@@ -247,7 +247,7 @@ int execute_cmd(char **args, char **redir_paths, enum e_redir_op *redir_types,
else if (cmd_code == EXIT && xe->pipe & CMD_PIPE)
return (PIPE_EXIT);
ret = command[cmd_code](args, xe);
if (cmd_code < 6)
if (cmd_code < 4)
{
if (ret == SUCCESS)
xe->stat_loc = 0;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment