summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-08-27 14:17:00 +0200
committerJozanLeClerc <bousset.rudy@gmail.com>2020-08-27 14:17:00 +0200
commit8205539da9d3e1b47eed9cd556113157233900eb (patch)
treef6fadb47db5bea0586c8e11b5e7d5f90bf11f6e4
parentTODO update (diff)
download42-minishell-8205539da9d3e1b47eed9cd556113157233900eb.tar.gz
42-minishell-8205539da9d3e1b47eed9cd556113157233900eb.tar.bz2
42-minishell-8205539da9d3e1b47eed9cd556113157233900eb.tar.xz
42-minishell-8205539da9d3e1b47eed9cd556113157233900eb.tar.zst
42-minishell-8205539da9d3e1b47eed9cd556113157233900eb.zip
Norm and TODO update
-rw-r--r--TODO.org1
-rw-r--r--src/m_argv.c19
2 files changed, 14 insertions, 6 deletions
diff --git a/TODO.org b/TODO.org
index 20acc28..2c460f9 100644
--- a/TODO.org
+++ b/TODO.org
@@ -26,6 +26,7 @@
** TODO [#B] $_
** DONE [#B] .minishellrc
** TODO [#B] .minishell_history
+** TODO [#B] SIGNAL
** TODO [#C] Norm
** DONE [#C] [ builtin <=== pretty cool yet simple stuff ( [ $a -eq 1 ] )
** TODO [#C] alias
diff --git a/src/m_argv.c b/src/m_argv.c
index 46e2640..5b2bc96 100644
--- a/src/m_argv.c
+++ b/src/m_argv.c
@@ -23,13 +23,23 @@
#include "m_mshrc.h"
#include "s_struct.h"
+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)
{
- int32_t fd;
-
if (argc == 1)
{
m_init_custom_vars(msh);
@@ -48,10 +58,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);
}