diff options
Diffstat (limited to '')
-rw-r--r-- | Makefile | 1 | ||||
-rw-r--r-- | src/f_com.c | 3 | ||||
-rw-r--r-- | src/f_fail.h | 1 | ||||
-rw-r--r-- | src/f_file.c | 31 | ||||
-rw-r--r-- | src/f_file.h | 20 | ||||
-rw-r--r-- | src/m_argv.c | 3 |
6 files changed, 57 insertions, 2 deletions
@@ -36,6 +36,7 @@ SRCS_NAME += f_chdir SRCS_NAME += f_com SRCS_NAME += f_errno SRCS_NAME += f_fail +SRCS_NAME += f_file SRCS_NAME += f_redir SRCS_NAME += f_shlvl SRCS_NAME += m_argv diff --git a/src/f_com.c b/src/f_com.c index 9c4e02a..5ca03eb 100644 --- a/src/f_com.c +++ b/src/f_com.c @@ -19,5 +19,6 @@ void f_fail_command_not_found(const char command[]) { - ft_dprintf(STDERR_FILENO, "%s: %s: %s\n", "minishell", command, FT_FAIL_COMMAND_NOT_FOUND); + ft_dprintf(STDERR_FILENO, "%s: %s: %s\n", "minishell", command, + FT_FAIL_COMMAND_NOT_FOUND); } diff --git a/src/f_fail.h b/src/f_fail.h index b1b3b8c..dfb46e3 100644 --- a/src/f_fail.h +++ b/src/f_fail.h @@ -17,6 +17,7 @@ #include "f_alloc.h" #include "f_chdir.h" #include "f_errno.h" +#include "f_file.h" #include "f_redir.h" #include "f_shlvl.h" #include "s_struct.h" diff --git a/src/f_file.c b/src/f_file.c new file mode 100644 index 0000000..c26596c --- /dev/null +++ b/src/f_file.c @@ -0,0 +1,31 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* f_file.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rbousset <marvin@42.fr> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/14 17:19:27 by rbousset #+# #+# */ +/* Updated: 2020/02/14 17:19:29 by rbousset ### ########lyon.fr */ +/* */ +/* ************************************************************************** */ + +#include <libft.h> +#include <stdlib.h> +#include <unistd.h> +#include <string.h> +#include <errno.h> + +#include "s_destroy.h" +#include "s_struct.h" + +void + f_open_file(char filename[], + t_msh *msh) +{ + ft_dprintf(STDERR_FILENO, "%s: %s: %s\n", msh->shname, + filename, + strerror(errno)); + s_destroy(msh); + exit(127); +} diff --git a/src/f_file.h b/src/f_file.h new file mode 100644 index 0000000..f34f038 --- /dev/null +++ b/src/f_file.h @@ -0,0 +1,20 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* f_file.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rbousset <marvin@42.fr> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/14 17:19:27 by rbousset #+# #+# */ +/* Updated: 2020/02/14 17:19:29 by rbousset ### ########lyon.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef F_FILE_H +#define F_FILE_H + +#include "s_struct.h" + +void f_open_file(char filename[], t_msh *msh); + +#endif diff --git a/src/m_argv.c b/src/m_argv.c index 1e23bae..0c32e3b 100644 --- a/src/m_argv.c +++ b/src/m_argv.c @@ -15,6 +15,7 @@ #include <fcntl.h> #include <unistd.h> +#include "f_fail.h" #include "d_define.h" #include "m_comm.h" #include "m_loop.h" @@ -44,7 +45,7 @@ uint8_t else { if ((fd = open(*(argv + 1), O_RDONLY)) < 0) - f_open_file(msh); + f_open_file(*(argv + 1), msh); msh->ret = m_loop(fd, msh); close(fd); } |