Commit af6b9869 authored by abenoit's avatar abenoit
Browse files

minor changes

parent 18ea4e58
......@@ -96,6 +96,8 @@ static int create_cmd(char **tmp, char **path, char **args)
return (NO_SUCH_FILE); // other error code
dir = ft_strjoin(path[dir_index], "/");
cmd = ft_strjoin(dir, args[0]);
if (cmd == NULL)
return (MALLOC_ERR);
free(dir);
*tmp = cmd;
return (SUCCESS);
......@@ -119,13 +121,14 @@ static int launch_ext(char **args, t_xe *xe)
{
int ret;
char *tmp;
char *cmd;
char **path;
ret = SUCCESS;
if (ft_strchr(args[0], '/') != NULL)
{
tmp = ft_strdup(args[0]);
if (tmp == NULL)
cmd = ft_strdup(args[0]);
if (cmd == NULL)
return (M_ERROR);
}
else
......@@ -147,16 +150,13 @@ static int launch_ext(char **args, t_xe *xe)
return (M_ERROR);
}
add_path_to_localdir(&path);
ret = create_cmd(&tmp, path, args);
ret = create_cmd(&cmd, path, args);
free_str_array(path);
if (ret != SUCCESS)
{
free(tmp);
return (ret);
}
}
ret = exec_cmd(tmp, args, xe);
free(tmp);
ret = exec_cmd(cmd, args, xe);
free(cmd);
return (ret);
}
......
......@@ -14,7 +14,7 @@ int parsing_error(int err_code, t_xe *xe)
"No redirection path specified",
"Empty command before ; or |"};
ft_putstr_fd("minishell: syntax error: ", STDERR_FILENO);
ft_putstr_fd("syntax error: ", STDERR_FILENO);
ft_putendl_fd(err_msg[err_code - _PARSING_ERROR_ - 1], STDERR_FILENO);
xe->stat_loc = 2;
return (SUCCESS);
......@@ -28,7 +28,7 @@ int exec_error(int err_code, t_xe *xe)
"HOME not set",
"No such file or directory"};
ft_putstr_fd("minishell: command error: ", STDERR_FILENO);
ft_putstr_fd("command error: ", STDERR_FILENO);
ft_putendl_fd(err_msg[err_code - _EXEC_ERROR_ - 1], STDERR_FILENO);
// have to set stat_loc as well !!!
if (err_code == HOME_NOT_SET)
......@@ -48,7 +48,7 @@ static int err_output(int err_code)
"Cannot write on standard output",
"Cannot read standard input (GNL error)"};
ft_putstr_fd("Error: ", STDERR_FILENO);
ft_putstr_fd("error: ", STDERR_FILENO);
ft_putstr_fd(err_msg[err_code - _ERRNO_MSG_], STDERR_FILENO);
ft_putstr_fd(": ", STDERR_FILENO); // besoin de faire comme perror?
ft_putendl_fd(strerror(errno), STDERR_FILENO); // strerror error?
......@@ -71,6 +71,7 @@ int clean_and_exit(int ret, t_xe *xe)
int ft_error(int ret, t_xe *xe)
{
ft_putstr_fd("minishell: ", STDERR_FILENO);
if (ret > _PARSING_ERROR_)// temp
return (parsing_error(ret, xe));
else if (ret > _EXEC_ERROR_)
......
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