summaryrefslogtreecommitdiffstats
path: root/src/ft_exec.c
diff options
context:
space:
mode:
authorRudy Bousset <rbousset@z2r5p6.le-101.fr>2019-11-01 18:57:16 +0100
committerRudy Bousset <rbousset@z2r5p6.le-101.fr>2019-11-01 18:57:16 +0100
commit7cbf04d592608cf36832e25f9b41619df733e0ae (patch)
tree96c0d2006cd53fcbc2a628795b45b118ba9f3189 /src/ft_exec.c
parentNow deals with history (diff)
download42-minishell-7cbf04d592608cf36832e25f9b41619df733e0ae.tar.gz
42-minishell-7cbf04d592608cf36832e25f9b41619df733e0ae.tar.bz2
42-minishell-7cbf04d592608cf36832e25f9b41619df733e0ae.tar.xz
42-minishell-7cbf04d592608cf36832e25f9b41619df733e0ae.tar.zst
42-minishell-7cbf04d592608cf36832e25f9b41619df733e0ae.zip
commit
Diffstat (limited to 'src/ft_exec.c')
-rw-r--r--src/ft_exec.c27
1 files changed, 24 insertions, 3 deletions
diff --git a/src/ft_exec.c b/src/ft_exec.c
index b9d50cf..dffaf3d 100644
--- a/src/ft_exec.c
+++ b/src/ft_exec.c
@@ -1,14 +1,35 @@
+/* ************************************************************************** */
+/* LE - / */
+/* / */
+/* ft_exec.c .:: .:/ . .:: */
+/* +:+:+ +: +: +:+:+ */
+/* By: rbousset <marvin@le-101.fr> +:+ +: +: +:+ */
+/* #+# #+ #+ #+# */
+/* Created: 2019/11/01 18:46:50 by rbousset #+# ## ## #+# */
+/* Updated: 2019/11/01 18:47:21 by rbousset ### #+. /#+ ###.fr */
+/* / */
+/* / */
+/* ************************************************************************** */
+
#include <libft.h>
#include <minishell.h>
#include <unistd.h>
int
-ft_exec(char **app)
+ft_exec(char **com)
{
uint8_t i;
i = 0;
- while (app[i])
+ while (com[i])
i++;
- return (execve(app[0] + 2, app, NULL));
+ if (!ft_strncmp(com[0], "./", 2))
+ {
+ if ((execve(com[0] + 2, com, NULL)) != 0)
+ return (ft_error(com[0], 127));
+ }
+ else
+ if ((execve(com[0] + 2, com, NULL)) != 0)
+ return (ft_error(com[0], 127));
+ return (0);
}