diff options
author | salad <fmoenne-@student.le-101.fr> | 2020-10-26 13:42:56 +0100 |
---|---|---|
committer | salad <fmoenne-@student.le-101.fr> | 2020-10-26 13:42:56 +0100 |
commit | 0277ddfac754ab4ad5bdd2b692e31a717efbe569 (patch) | |
tree | 49d7c5fd3a12248af85e2c3a3254bc1538ae5775 /src/m_argv.c | |
parent | reqdy for MERGE (diff) | |
parent | TODO update (diff) | |
download | 42-minishell-0277ddfac754ab4ad5bdd2b692e31a717efbe569.tar.gz 42-minishell-0277ddfac754ab4ad5bdd2b692e31a717efbe569.tar.bz2 42-minishell-0277ddfac754ab4ad5bdd2b692e31a717efbe569.tar.xz 42-minishell-0277ddfac754ab4ad5bdd2b692e31a717efbe569.tar.zst 42-minishell-0277ddfac754ab4ad5bdd2b692e31a717efbe569.zip |
merge wif master
Diffstat (limited to 'src/m_argv.c')
-rw-r--r-- | src/m_argv.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/m_argv.c b/src/m_argv.c index 46e2640..98a8e3e 100644 --- a/src/m_argv.c +++ b/src/m_argv.c @@ -23,13 +23,20 @@ #include "m_mshrc.h" #include "s_struct.h" -uint8_t - m_argv(int argc, - char *const argv[], - t_msh *msh) +static void + m_read_script(char *const argv[], t_msh *msh) { int32_t fd; + if ((fd = open(*(argv + 1), O_RDONLY)) == -1) + f_open_file(*(argv + 1), msh); + msh->ret = m_loop(fd, msh); + close(fd); +} + +uint8_t + m_argv(int argc, char *const argv[], t_msh *msh) +{ if (argc == 1) { m_init_custom_vars(msh); @@ -48,10 +55,7 @@ uint8_t } else { - if ((fd = open(*(argv + 1), O_RDONLY)) < 0) - f_open_file(*(argv + 1), msh); - msh->ret = m_loop(fd, msh); - close(fd); + m_read_script(argv, msh); } return (msh->ret); } |