aboutsummaryrefslogtreecommitdiff
path: root/src/eval
diff options
context:
space:
mode:
authorCharles <sircharlesaze@gmail.com>2020-07-19 19:27:52 +0200
committerCharles <sircharlesaze@gmail.com>2020-07-19 19:27:52 +0200
commit6e456095fce214a2eadea0cafa3fa7ea1113b4e6 (patch)
tree42d255dc5042f1df8079567e7ca3426d22cba24d /src/eval
parenta478d95bed0f24f9783714600af48a6c1cde2aae (diff)
downloadminishell-6e456095fce214a2eadea0cafa3fa7ea1113b4e6.tar.gz
minishell-6e456095fce214a2eadea0cafa3fa7ea1113b4e6.tar.bz2
minishell-6e456095fce214a2eadea0cafa3fa7ea1113b4e6.zip
Added errof for cleaner error message, Removed previous error functions
Diffstat (limited to 'src/eval')
-rw-r--r--src/eval/cmd.c16
-rw-r--r--src/eval/redir.c4
2 files changed, 6 insertions, 14 deletions
diff --git a/src/eval/cmd.c b/src/eval/cmd.c
index a7a6f71..87c9bbf 100644
--- a/src/eval/cmd.c
+++ b/src/eval/cmd.c
@@ -6,7 +6,7 @@
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/06/14 10:41:31 by charles #+# #+# */
-/* Updated: 2020/07/19 16:53:54 by charles ### ########.fr */
+/* Updated: 2020/07/19 19:00:54 by charles ### ########.fr */
/* */
/* ************************************************************************** */
@@ -74,19 +74,12 @@ int forked_cmd(void *void_param)
struct stat statbuf;
if (stat(param->exec_path, &statbuf) != -1 && S_ISDIR(statbuf.st_mode))
{
- ft_putstr_fd(g_basename, STDERR_FILENO);
- ft_putstr_fd(": ", STDERR_FILENO);
- ft_putstr_fd(param->exec_path, STDERR_FILENO);
- ft_putendl_fd(": Is a directory", STDERR_FILENO);
+ errorf("%s: Is a directory\n", param->exec_path);
ret = 126;
}
else
{
- ft_putstr_fd(g_basename, STDERR_FILENO);
- ft_putstr_fd(": ", STDERR_FILENO);
- ft_putstr_fd(param->exec_path, STDERR_FILENO);
- ft_putstr_fd(": ", STDERR_FILENO);
- ft_putendl_fd(strerror(errno), STDERR_FILENO);
+ errorf("%s: %s\n", param->exec_path, strerror(errno));
ret = 126;
}
}
@@ -121,7 +114,6 @@ int eval_cmd(int fds[2], t_env env, t_path path, t_ast *ast)
ft_vecpop(param.env_local, NULL);
if (ft_vecswallow_at(env, env->size - 1, param.env_local) == NULL)
{
- /* printf("hyo\n"); */
ft_vecdestroy(param.env_local, free);
return (-1);
}
@@ -146,7 +138,7 @@ int eval_cmd(int fds[2], t_env env, t_path path, t_ast *ast)
if (param.exec_path == NULL)
{
g_last_status_code = 127;
- error_eval_put(ERROR_CMD_NOT_FOUND, argv[0]);
+ errorf("%s: command not found\n", argv[0]);
ft_split_destroy(argv);
return (-1); // return error status
}
diff --git a/src/eval/redir.c b/src/eval/redir.c
index 7249ad5..49cfa1d 100644
--- a/src/eval/redir.c
+++ b/src/eval/redir.c
@@ -6,7 +6,7 @@
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/06/15 11:05:34 by charles #+# #+# */
-/* Updated: 2020/06/17 16:17:43 by charles ### ########.fr */
+/* Updated: 2020/07/19 18:57:03 by charles ### ########.fr */
/* */
/* ************************************************************************** */
@@ -27,7 +27,7 @@ static bool st_open_replace(int *fd, char *filename, int oflag)
*fd = open(filename, oflag);
if (*fd == -1)
{
- error_eval_put(ERROR_OPEN, filename);
+ errorf("%s: %s\n", filename, strerror(errno));
free(filename);
return (false);
}