summaryrefslogtreecommitdiffstats
path: root/src/ft_m_argv.c
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-04-25 17:35:48 +0200
committerJozanLeClerc <bousset.rudy@gmail.com>2020-04-25 17:35:48 +0200
commitc293dfa39ef25e37d889206cf5bc47d91e330869 (patch)
tree9f6984e7f45e5e61827c79cf77c097f701bb7749 /src/ft_m_argv.c
parentStupid bash rule (diff)
download42-minishell-c293dfa39ef25e37d889206cf5bc47d91e330869.tar.gz
42-minishell-c293dfa39ef25e37d889206cf5bc47d91e330869.tar.bz2
42-minishell-c293dfa39ef25e37d889206cf5bc47d91e330869.tar.xz
42-minishell-c293dfa39ef25e37d889206cf5bc47d91e330869.tar.zst
42-minishell-c293dfa39ef25e37d889206cf5bc47d91e330869.zip
Now handles -c option
Diffstat (limited to '')
-rw-r--r--src/ft_m_argv.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/ft_m_argv.c b/src/ft_m_argv.c
index a4da580..389fbe7 100644
--- a/src/ft_m_argv.c
+++ b/src/ft_m_argv.c
@@ -14,6 +14,7 @@
#include <stdint.h>
#include "ft_d_define.h"
+#include "ft_m_comm.h"
#include "ft_m_loop.h"
#include "ft_s_struct.h"
@@ -22,19 +23,21 @@ uint8_t
const char *argv[],
t_msh *msh)
{
- int32_t i;
-
- (void)argv;
+ /* TODO: better argv handling */
if (argc == 1)
{
msh->ret = ft_m_loop(msh);
return (msh->ret);
}
- i = 1;
- while (i < argc)
+ if (!ft_strncmp(*(argv + 1), FT_OPT_COMMAND, 3))
{
- /* if (ft_strncmp(*(argv + i), )) */
- i++;
+ if (*(argv + 2) == NULL)
+ {
+ ft_dprintf(2, "%s: %s: option requires an argument",
+ msh->shname, FT_OPT_COMMAND);
+ return (2);
+ }
+ msh->ret = ft_m_comm(*(argv + 2), msh);
}
return (msh->ret);
}