summaryrefslogtreecommitdiffstats
path: root/src/m_argv.c
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-09-19 16:59:38 +0200
committerJozanLeClerc <bousset.rudy@gmail.com>2020-09-19 16:59:38 +0200
commit49b6183dc0171ac040bdd2faf6f8efa0448567c5 (patch)
treeeaff08562cedef9bf4267b0d17efce0485d2f51e /src/m_argv.c
parentTODO update (diff)
download42-minishell-49b6183dc0171ac040bdd2faf6f8efa0448567c5.tar.gz
42-minishell-49b6183dc0171ac040bdd2faf6f8efa0448567c5.tar.bz2
42-minishell-49b6183dc0171ac040bdd2faf6f8efa0448567c5.tar.xz
42-minishell-49b6183dc0171ac040bdd2faf6f8efa0448567c5.tar.zst
42-minishell-49b6183dc0171ac040bdd2faf6f8efa0448567c5.zip
Cleaner variables handling $0 $1 $2 $3
Diffstat (limited to 'src/m_argv.c')
-rw-r--r--src/m_argv.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/m_argv.c b/src/m_argv.c
index 7661ef7..bd415ec 100644
--- a/src/m_argv.c
+++ b/src/m_argv.c
@@ -56,6 +56,8 @@ static void m_read_script(char *const argv[], t_msh *msh)
if ((fd = open(*(argv + 1), O_RDONLY)) == -1)
f_open_file(*(argv + 1), msh);
msh->fd = fd;
+ msh->argv = (char**)(argv + 1);
+ msh->argc -= 1;
msh->ret = m_loop(fd, msh);
close(fd);
}
@@ -75,7 +77,7 @@ uint8_t m_argv(int argc, char *const argv[], t_msh *msh)
if (*(argv + 2) == NULL)
{
ft_dprintf(STDERR_FILENO, "%s: %s: option requires an argument\n",
- msh->shname, FT_OPT_COMMAND);
+ msh->argv[0], FT_OPT_COMMAND);
return (2);
}
msh->ret = m_comm(*(argv + 2), msh);