rectif gestion fichier/dossier executé
This commit is contained in:
parent
943386174f
commit
09a5cbb927
5 changed files with 8 additions and 14 deletions
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/11/07 13:33:27 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/20 16:10:35 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/20 16:13:24 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/11/03 14:57:33 by jhalford #+# #+# */
|
||||
/* Updated: 2016/11/16 12:23:13 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/20 16:19:07 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/03/08 00:58:02 by wescande #+# #+# */
|
||||
/* Updated: 2017/03/13 22:31:32 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/20 16:23:12 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/03/07 14:53:31 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/17 20:22:38 by wescande ### ########.fr */
|
||||
/* Updated: 2017/03/20 16:26:53 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -22,7 +22,7 @@ int plaunch_file(t_process *p)
|
|||
{
|
||||
if (!p->data.cmd.path)
|
||||
error_launch("command not found: ", p->data.cmd.av[0], 127);
|
||||
else if (!p->data.cmd.stat)
|
||||
else if (access(p->data.cmd.path, F_OK) == -1)
|
||||
error_launch(p->data.cmd.av[0], ": no such file or directory", 127);
|
||||
else if (S_ISDIR(p->data.cmd.stat->st_mode))
|
||||
error_launch(p->data.cmd.av[0], ": is a directory", 126);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/03/20 12:41:54 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/20 15:39:40 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/20 16:28:02 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -28,19 +28,13 @@ int pset_cmd(t_process *p, t_btree *ast)
|
|||
p->type = PROCESS_BUILTIN;
|
||||
else if ((p->type = PROCESS_FILE))
|
||||
{
|
||||
DG();
|
||||
p->data.cmd.stat = ft_memalloc(sizeof(struct stat));
|
||||
p->data.cmd.execf = &execve;
|
||||
p->data.cmd.path = ft_strchr(p->data.cmd.av[0], '/') ?
|
||||
ft_strdup(p->data.cmd.av[0]) : ft_hash(p->data.cmd.av[0]);
|
||||
if (stat(p->data.cmd.path, p->data.cmd.stat) == -1)
|
||||
{
|
||||
ft_memdel((void**)&p->data.cmd.stat);
|
||||
ft_dprintf(2, "{red}%s: %s: unexpected stat (2) failure\n",
|
||||
SHELL_NAME, p->data.cmd.path);
|
||||
if (p->data.cmd.path && !access(p->data.cmd.path, F_OK)
|
||||
&& stat(p->data.cmd.path, p->data.cmd.stat) == -1)
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
DG();
|
||||
return (0);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue