Clean-up: normed out files
This commit is contained in:
parent
d22bc173f1
commit
85af14cd9f
@ -6,13 +6,13 @@
|
||||
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/09/20 14:42:42 by tmaze #+# #+# */
|
||||
/* Updated: 2019/09/26 15:26:44 by tmaze ### ########.fr */
|
||||
/* Updated: 2019/10/17 10:59:38 by tmaze ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "minishell.h"
|
||||
|
||||
int cmd_cd(char** argv, t_env** env)
|
||||
int cmd_cd(char **argv, t_env **env)
|
||||
{
|
||||
(void)argv;
|
||||
(void)env;
|
||||
|
@ -6,13 +6,13 @@
|
||||
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/09/20 14:42:30 by tmaze #+# #+# */
|
||||
/* Updated: 2019/09/26 15:26:53 by tmaze ### ########.fr */
|
||||
/* Updated: 2019/10/17 10:58:52 by tmaze ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "minishell.h"
|
||||
|
||||
int cmd_echo(char** argv, t_env** env)
|
||||
int cmd_echo(char **argv, t_env **env)
|
||||
{
|
||||
(void)argv;
|
||||
(void)env;
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/09/20 14:33:48 by tmaze #+# #+# */
|
||||
/* Updated: 2019/10/10 13:49:33 by tmaze ### ########.fr */
|
||||
/* Updated: 2019/10/17 10:07:21 by tmaze ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -39,7 +39,7 @@ t_env *envcpy(t_env *env)
|
||||
return (cpy);
|
||||
}
|
||||
|
||||
int cmd_env(char** argv, t_env** env)
|
||||
int cmd_env(char **argv, t_env **env)
|
||||
{
|
||||
int i;
|
||||
t_env *it;
|
||||
@ -48,7 +48,7 @@ int cmd_env(char** argv, t_env** env)
|
||||
|
||||
i = 1;
|
||||
env_cp = NULL;
|
||||
if (!ft_strequ(argv[i] , "-i") && (env != NULL))
|
||||
if (!ft_strequ(argv[i], "-i") && (env != NULL))
|
||||
{
|
||||
it = *env;
|
||||
while (it)
|
||||
@ -63,8 +63,8 @@ int cmd_env(char** argv, t_env** env)
|
||||
it = it->next;
|
||||
}
|
||||
}
|
||||
if (ft_strequ(argv[i] , "-i"))
|
||||
i++;
|
||||
if (ft_strequ(argv[i], "-i"))
|
||||
i++;
|
||||
if (argv[i])
|
||||
exec_cmd(argv + i, &env_cp);
|
||||
else
|
||||
|
@ -6,13 +6,13 @@
|
||||
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/09/20 14:41:08 by tmaze #+# #+# */
|
||||
/* Updated: 2019/10/10 14:31:47 by tmaze ### ########.fr */
|
||||
/* Updated: 2019/10/17 09:59:40 by tmaze ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "minishell.h"
|
||||
|
||||
int cmd_setenv(char** argv, t_env** env)
|
||||
int cmd_setenv(char **argv, t_env **env)
|
||||
{
|
||||
t_env *new;
|
||||
|
||||
@ -20,10 +20,14 @@ int cmd_setenv(char** argv, t_env** env)
|
||||
{
|
||||
lstaddend(env, new);
|
||||
return (0);
|
||||
} else if (argv[1]) {
|
||||
}
|
||||
else if (argv[1])
|
||||
{
|
||||
ft_printf("minishell: setenv: memory error\n");
|
||||
return (2);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("usage: setenv [KEY]=[value]\n");
|
||||
return (1);
|
||||
}
|
||||
|
@ -6,13 +6,13 @@
|
||||
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/09/20 14:42:01 by tmaze #+# #+# */
|
||||
/* Updated: 2019/10/10 16:05:56 by tmaze ### ########.fr */
|
||||
/* Updated: 2019/10/17 10:58:23 by tmaze ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "minishell.h"
|
||||
|
||||
int cmd_unsetenv(char** argv, t_env** env)
|
||||
int cmd_unsetenv(char **argv, t_env **env)
|
||||
{
|
||||
t_env **it;
|
||||
t_env *tmp;
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/09/20 11:43:53 by tmaze #+# #+# */
|
||||
/* Updated: 2019/09/27 16:21:14 by tmaze ### ########.fr */
|
||||
/* Updated: 2019/10/17 11:02:54 by tmaze ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -103,7 +103,7 @@ char **lsttotab(t_env *env)
|
||||
while (it)
|
||||
{
|
||||
size = ft_strlen(it->key) + ft_strlen(it->val) + 1;
|
||||
if ((new = ft_strnew(size)) == NULL)
|
||||
if ((new = ft_strnew(size)) == NULL)
|
||||
{
|
||||
ft_del_words_tables(&ret);
|
||||
break ;
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/09/26 16:25:00 by tmaze #+# #+# */
|
||||
/* Updated: 2019/10/10 14:05:31 by tmaze ### ########.fr */
|
||||
/* Updated: 2019/10/17 11:01:38 by tmaze ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -78,7 +78,7 @@ char *check_path_dot(char *exec, t_env *env)
|
||||
put_error(exec, "permission denied");
|
||||
ft_strdel(&ret);
|
||||
return (exec);
|
||||
}
|
||||
}
|
||||
put_error(exec, "no such file or directory");
|
||||
ft_strdel(&ret);
|
||||
return (exec);
|
||||
@ -96,19 +96,9 @@ char *check_path(char *exec, t_env *env)
|
||||
if (exec)
|
||||
{
|
||||
if (ft_isin(exec, '/') != -1 && ft_isin(exec, '.') == -1)
|
||||
{
|
||||
if ((ret = check_path_slash(exec)) != NULL)
|
||||
return (ret);
|
||||
else
|
||||
return (NULL);
|
||||
}
|
||||
return (check_path_slash(exec));
|
||||
if (exec[0] == '.')
|
||||
{
|
||||
if ((ret = check_path_dot(exec, env)) != NULL)
|
||||
return (ret);
|
||||
else
|
||||
return (NULL);
|
||||
}
|
||||
return (check_path_dot(exec, env));
|
||||
if ((path = lstgetelem("PATH", env)) == NULL
|
||||
|| path->val == NULL
|
||||
|| (path_elems = ft_strsplit(path->val, ':')) == NULL)
|
||||
@ -135,6 +125,9 @@ char *check_path(char *exec, t_env *env)
|
||||
if (access(ret, X_OK) == 0)
|
||||
break ;
|
||||
put_error(exec, "permission denied");
|
||||
ft_strdel(&ret);
|
||||
ft_del_words_tables(&path_elems);
|
||||
return (NULL);
|
||||
}
|
||||
ft_strdel(&ret);
|
||||
i++;
|
||||
@ -156,6 +149,7 @@ int exec_cmd(char **argv, t_env **env)
|
||||
return (-1);
|
||||
if ((path = check_path(argv[0], *env)) == NULL)
|
||||
ft_del_words_tables(&env_tab);
|
||||
ft_printf("path after resolve: %s\n", path);
|
||||
if (path == NULL)
|
||||
return (-1);
|
||||
if ((ret = fork()) == 0)
|
||||
|
Loading…
x
Reference in New Issue
Block a user