work
This commit is contained in:
parent
8283472d2e
commit
c5467769d9
BIN
.main.c.swp
Normal file
BIN
.main.c.swp
Normal file
Binary file not shown.
BIN
.minishell.h.swp
BIN
.minishell.h.swp
Binary file not shown.
2
Makefile
2
Makefile
@ -1,4 +1,4 @@
|
|||||||
UTILS_SRC = utils/ft_is_in_quote.c utils/ft_strncpy.c utils/ft_strreplace.c utils/ft_strnchr.c utils/ft_getstr.c
|
UTILS_SRC = utils/ft_is_in_quote.c utils/ft_strncpy.c utils/ft_strreplace.c utils/ft_strnchr.c utils/ft_getstr.c utils/ft_printn.c
|
||||||
SRCS = ${UTILS_SRC} main.c file.c infile.c outfile.c heredoc.c syntatics.c ft_split_quoted.c env.c execution.c
|
SRCS = ${UTILS_SRC} main.c file.c infile.c outfile.c heredoc.c syntatics.c ft_split_quoted.c env.c execution.c
|
||||||
|
|
||||||
OBJS = ${SRCS:.c=.o}
|
OBJS = ${SRCS:.c=.o}
|
||||||
|
26
builtin/env.c
Normal file
26
builtin/env.c
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* env.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2023/02/14 14:56:02 by cchauvet #+# #+# */
|
||||||
|
/* Updated: 2023/02/14 14:58:40 by cchauvet ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "../minishell.h"
|
||||||
|
|
||||||
|
int main(char **env)
|
||||||
|
{
|
||||||
|
t_list **head;
|
||||||
|
t_list *current;
|
||||||
|
|
||||||
|
while (current != NULL)
|
||||||
|
{
|
||||||
|
ft_putendl_fd(1, current->content);
|
||||||
|
current = current->next;
|
||||||
|
}
|
||||||
|
return (0);
|
||||||
|
}
|
40
builtin/export.c
Normal file
40
builtin/export.c
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* export.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2023/02/14 14:27:08 by cchauvet #+# #+# */
|
||||||
|
/* Updated: 2023/02/14 14:52:50 by cchauvet ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "../minishell.h"
|
||||||
|
|
||||||
|
int main(char **env)
|
||||||
|
{
|
||||||
|
t_list **env_lst;
|
||||||
|
t_list *current;
|
||||||
|
char *key;
|
||||||
|
char *value;
|
||||||
|
|
||||||
|
env_lst = init_env(env);
|
||||||
|
current = *env_lst;
|
||||||
|
while (current != NULL)
|
||||||
|
{
|
||||||
|
value = ft_strchr(current->content, '=') + 1;
|
||||||
|
key = ft_strndup(current->content,
|
||||||
|
ft_strlen(current->content) - ft_strlen(value));
|
||||||
|
if (key == NULL)
|
||||||
|
{
|
||||||
|
ft_lstclear(env_lst, env_del);
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
ft_printf("declare -x %s=\"%s\"\n", key, value);
|
||||||
|
free(key);
|
||||||
|
current = current->next;
|
||||||
|
}
|
||||||
|
ft_lstclear(env_lst, env_del);
|
||||||
|
return (0);
|
||||||
|
}
|
103
env.c
103
env.c
@ -6,57 +6,17 @@
|
|||||||
/* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/02/02 14:39:56 by erey-bet #+# #+# */
|
/* Created: 2023/02/02 14:39:56 by erey-bet #+# #+# */
|
||||||
/* Updated: 2023/02/14 07:32:43 by cchauvet ### ########.fr */
|
/* Updated: 2023/02/14 15:21:28 by cchauvet ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "libftx/libftx.h"
|
||||||
#include "minishell.h"
|
#include "minishell.h"
|
||||||
|
#include "utils/utils.h"
|
||||||
|
|
||||||
int get_index(char *s, char c)
|
void env_del(void *content)
|
||||||
{
|
{
|
||||||
int i;
|
(void) content;
|
||||||
|
|
||||||
i = -1;
|
|
||||||
while (s[++i])
|
|
||||||
if (s[i] == c)
|
|
||||||
return (i);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void print_export(t_list **head, int fd)
|
|
||||||
{
|
|
||||||
t_list *current;
|
|
||||||
char *ctn;
|
|
||||||
int v;
|
|
||||||
|
|
||||||
current = *head;
|
|
||||||
while (current != NULL)
|
|
||||||
{
|
|
||||||
ctn = current->content;
|
|
||||||
if (*(ft_strchr(ctn, '=') - 1) != '_')
|
|
||||||
{
|
|
||||||
v = get_index(ctn, '=');
|
|
||||||
write(fd, "declare -x ", 11);
|
|
||||||
write(fd, ctn, v + 1);
|
|
||||||
write(fd, "\"", 1);
|
|
||||||
ft_putstr_fd(ctn + v + 1, fd);
|
|
||||||
write(fd, "\"\n", 2);
|
|
||||||
}
|
|
||||||
current = current->next;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void print_env(t_list **head, int fd)
|
|
||||||
{
|
|
||||||
t_list *current;
|
|
||||||
|
|
||||||
current = *head;
|
|
||||||
while (current != NULL)
|
|
||||||
{
|
|
||||||
ft_putstr_fd(current->content, fd);
|
|
||||||
write(fd, "\n", 1);
|
|
||||||
current = current->next;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int strcmp_alphabet(char *s1, char *s2)
|
int strcmp_alphabet(char *s1, char *s2)
|
||||||
@ -139,22 +99,6 @@ char *get_value_by_index(int index, t_list **head)
|
|||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int is_start(char *big, char *little)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
i = 0;
|
|
||||||
while (big[i])
|
|
||||||
{
|
|
||||||
if (little[i] != big[i])
|
|
||||||
return (0);
|
|
||||||
i++;
|
|
||||||
if (!little[i])
|
|
||||||
return (1);
|
|
||||||
}
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
char *get_value_by_key(char *key, t_list **head)
|
char *get_value_by_key(char *key, t_list **head)
|
||||||
{
|
{
|
||||||
t_list *current;
|
t_list *current;
|
||||||
@ -162,13 +106,39 @@ char *get_value_by_key(char *key, t_list **head)
|
|||||||
current = *head;
|
current = *head;
|
||||||
while (current != NULL)
|
while (current != NULL)
|
||||||
{
|
{
|
||||||
if (is_start(current->content, key))
|
if (ft_strncmp(current->content, key, ft_strlen(key)))
|
||||||
return (ft_strchr(current->content, '=') + 1);
|
return (ft_strchr(current->content, '=') + 1);
|
||||||
current = current->next;
|
current = current->next;
|
||||||
}
|
}
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int set_value_by_key(t_list **env, char *key, char *value)
|
||||||
|
{
|
||||||
|
t_list *current;
|
||||||
|
char *temp;
|
||||||
|
|
||||||
|
current = *env;
|
||||||
|
while (current != NULL)
|
||||||
|
{
|
||||||
|
if (!ft_strncmp(key, current->content, ft_strlen(current->content)))
|
||||||
|
{
|
||||||
|
temp = current->content;
|
||||||
|
current->content = ft_strreplace(temp, value,
|
||||||
|
ft_strnchr(temp, '=') + 1,
|
||||||
|
ft_strlen(temp) - (ft_strnchr(temp, '=') - 1));
|
||||||
|
free(temp);
|
||||||
|
if (current->content == NULL)
|
||||||
|
{
|
||||||
|
ft_eprintf("minishell: malloc failed");
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
current = current->next;
|
||||||
|
}
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
t_list **init_env(char **env)
|
t_list **init_env(char **env)
|
||||||
{
|
{
|
||||||
t_list **head;
|
t_list **head;
|
||||||
@ -183,12 +153,3 @@ t_list **init_env(char **env)
|
|||||||
add_sort(head, env[i]);
|
add_sort(head, env[i]);
|
||||||
return (head);
|
return (head);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*int main(int argc, char *argv[], char **env)
|
|
||||||
{
|
|
||||||
(void)argc;
|
|
||||||
(void)argv;
|
|
||||||
ft_putstr_fd(get_value_index(10, init_env(env)), 1);
|
|
||||||
//print_env(init_env(env), 1);
|
|
||||||
return (0);
|
|
||||||
}*/
|
|
||||||
|
51
execution.c
51
execution.c
@ -8,10 +8,11 @@ static char *ft_get_variable(char **env, char *variable)
|
|||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
while (env[i] == NULL)
|
while (env[i] != NULL)
|
||||||
{
|
{
|
||||||
if (ft_strncmp(variable, env[1], ft_strlen(variable)))
|
if (ft_strncmp(variable, env[i], ft_strlen(variable)) == 0)
|
||||||
return (ft_strchr(env[1], '=') + 1);
|
return (ft_strchr(env[i], '=') + 1);
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
@ -19,11 +20,13 @@ static char *ft_get_variable(char **env, char *variable)
|
|||||||
static char *ft_get_executable_path(char *executable_name, char **env)
|
static char *ft_get_executable_path(char *executable_name, char **env)
|
||||||
{
|
{
|
||||||
char *path;
|
char *path;
|
||||||
|
char *temp;
|
||||||
char **tab;
|
char **tab;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
|
path = NULL;
|
||||||
if (executable_name[0] == '.' || executable_name[0] == '/')
|
if (executable_name[0] == '.' || executable_name[0] == '/')
|
||||||
path = executable_name;
|
path = ft_strdup(executable_name);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
tab = ft_split(ft_get_variable(env, "PATH"), ':');
|
tab = ft_split(ft_get_variable(env, "PATH"), ':');
|
||||||
@ -32,14 +35,25 @@ static char *ft_get_executable_path(char *executable_name, char **env)
|
|||||||
i = 0;
|
i = 0;
|
||||||
while (tab[i] != NULL)
|
while (tab[i] != NULL)
|
||||||
{
|
{
|
||||||
if (access(tab[i], X_OK) == 0)
|
temp = ft_strmerger(3, tab[i], "/", executable_name);
|
||||||
|
if (temp == NULL)
|
||||||
{
|
{
|
||||||
path = ft_strmerger(3, tab[i], "/", executable_name);
|
ft_freer_tab_ultimate(1, tab);
|
||||||
free(executable_name);
|
free(executable_name);
|
||||||
|
ft_eprintf("minishell: malloc failed\n");
|
||||||
|
}
|
||||||
|
if (access(temp, X_OK) == 0)
|
||||||
|
{
|
||||||
|
path = temp;
|
||||||
break ;
|
break ;
|
||||||
}
|
}
|
||||||
|
free(temp);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
if (path == NULL)
|
||||||
|
{
|
||||||
|
ft_eprintf("%s: command not found\n", executable_name);
|
||||||
|
}
|
||||||
ft_freer_tab_ultimate(1, tab);
|
ft_freer_tab_ultimate(1, tab);
|
||||||
}
|
}
|
||||||
return (path);
|
return (path);
|
||||||
@ -48,7 +62,6 @@ static char *ft_get_executable_path(char *executable_name, char **env)
|
|||||||
static int ft_excutor(t_cmd *cmd, char **env)
|
static int ft_excutor(t_cmd *cmd, char **env)
|
||||||
{
|
{
|
||||||
int pid;
|
int pid;
|
||||||
char *executable;
|
|
||||||
int return_value;
|
int return_value;
|
||||||
|
|
||||||
pid = fork();
|
pid = fork();
|
||||||
@ -58,7 +71,7 @@ static int ft_excutor(t_cmd *cmd, char **env)
|
|||||||
{
|
{
|
||||||
dup2(cmd->fd_out, 1);
|
dup2(cmd->fd_out, 1);
|
||||||
dup2(cmd->fd_in, 0);
|
dup2(cmd->fd_in, 0);
|
||||||
execve(executable, cmd->args, env);
|
execve(cmd->executable, cmd->args, env);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
waitpid(pid, &return_value, 0);
|
waitpid(pid, &return_value, 0);
|
||||||
@ -72,16 +85,24 @@ int ft_cmds_executor(t_list **cmds, char **env)
|
|||||||
int fds[2];
|
int fds[2];
|
||||||
|
|
||||||
current = *cmds;
|
current = *cmds;
|
||||||
while (current->next != NULL)
|
while (current != NULL)
|
||||||
{
|
{
|
||||||
if (pipe(fds) == -1)
|
content = current->content;
|
||||||
|
if (current->next != NULL)
|
||||||
{
|
{
|
||||||
ft_eprintf("minishell: pipe failed");
|
if (pipe(fds) == -1)
|
||||||
return (1);
|
{
|
||||||
|
ft_eprintf("minishell: pipe failed\n");
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
content->fd_out = fds[1];
|
||||||
|
((t_cmd *) current->next->content)->fd_in = fds[0];
|
||||||
}
|
}
|
||||||
content->fd_out = fds[1];
|
content->executable = ft_get_executable_path(content->executable, env);
|
||||||
((t_cmd *) current->next)->fd_in = fds[0];
|
if (content->executable != NULL)
|
||||||
ft_excutor(content, env);
|
ft_excutor(content, env);
|
||||||
|
close(content->fd_in);
|
||||||
|
close(content->fd_out);
|
||||||
current = current->next;
|
current = current->next;
|
||||||
}
|
}
|
||||||
return (0);
|
return (0);
|
||||||
|
BIN
execution.o
Normal file
BIN
execution.o
Normal file
Binary file not shown.
BIN
ft_split_quoted.o
Normal file
BIN
ft_split_quoted.o
Normal file
Binary file not shown.
BIN
libftx/extra/extra.a
Normal file
BIN
libftx/extra/extra.a
Normal file
Binary file not shown.
BIN
libftx/extra/ft_contain_only.o
Normal file
BIN
libftx/extra/ft_contain_only.o
Normal file
Binary file not shown.
BIN
libftx/extra/ft_freer.o
Normal file
BIN
libftx/extra/ft_freer.o
Normal file
Binary file not shown.
BIN
libftx/extra/ft_is_in.o
Normal file
BIN
libftx/extra/ft_is_in.o
Normal file
Binary file not shown.
BIN
libftx/extra/ft_random_generator.o
Normal file
BIN
libftx/extra/ft_random_generator.o
Normal file
Binary file not shown.
BIN
libftx/extra/ft_strchri.o
Normal file
BIN
libftx/extra/ft_strchri.o
Normal file
Binary file not shown.
BIN
libftx/extra/ft_strcmp.o
Normal file
BIN
libftx/extra/ft_strcmp.o
Normal file
Binary file not shown.
BIN
libftx/extra/ft_strfjoin.o
Normal file
BIN
libftx/extra/ft_strfjoin.o
Normal file
Binary file not shown.
BIN
libftx/extra/ft_strgen.o
Normal file
BIN
libftx/extra/ft_strgen.o
Normal file
Binary file not shown.
BIN
libftx/extra/ft_strmerger.o
Normal file
BIN
libftx/extra/ft_strmerger.o
Normal file
Binary file not shown.
BIN
libftx/extra/ft_strndup.o
Normal file
BIN
libftx/extra/ft_strndup.o
Normal file
Binary file not shown.
BIN
libftx/extra/ft_swap.o
Normal file
BIN
libftx/extra/ft_swap.o
Normal file
Binary file not shown.
BIN
libftx/extra/ft_tabrealloc.o
Normal file
BIN
libftx/extra/ft_tabrealloc.o
Normal file
Binary file not shown.
BIN
libftx/extra/ft_ultoa_base.o
Normal file
BIN
libftx/extra/ft_ultoa_base.o
Normal file
Binary file not shown.
BIN
libftx/gnl/get_next_line.a
Normal file
BIN
libftx/gnl/get_next_line.a
Normal file
Binary file not shown.
BIN
libftx/gnl/get_next_line.o
Normal file
BIN
libftx/gnl/get_next_line.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_atoi.o
Normal file
BIN
libftx/libft/ft_atoi.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_bzero.o
Normal file
BIN
libftx/libft/ft_bzero.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_calloc.o
Normal file
BIN
libftx/libft/ft_calloc.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_isalnum.o
Normal file
BIN
libftx/libft/ft_isalnum.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_isalpha.o
Normal file
BIN
libftx/libft/ft_isalpha.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_isascii.o
Normal file
BIN
libftx/libft/ft_isascii.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_isdigit.o
Normal file
BIN
libftx/libft/ft_isdigit.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_isprint.o
Normal file
BIN
libftx/libft/ft_isprint.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_itoa.o
Normal file
BIN
libftx/libft/ft_itoa.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_lstadd_back.o
Normal file
BIN
libftx/libft/ft_lstadd_back.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_lstadd_front.o
Normal file
BIN
libftx/libft/ft_lstadd_front.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_lstclear.o
Normal file
BIN
libftx/libft/ft_lstclear.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_lstdelone.o
Normal file
BIN
libftx/libft/ft_lstdelone.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_lstiter.o
Normal file
BIN
libftx/libft/ft_lstiter.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_lstlast.o
Normal file
BIN
libftx/libft/ft_lstlast.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_lstmap.o
Normal file
BIN
libftx/libft/ft_lstmap.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_lstnew.o
Normal file
BIN
libftx/libft/ft_lstnew.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_lstsize.o
Normal file
BIN
libftx/libft/ft_lstsize.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_memchr.o
Normal file
BIN
libftx/libft/ft_memchr.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_memcmp.o
Normal file
BIN
libftx/libft/ft_memcmp.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_memcpy.o
Normal file
BIN
libftx/libft/ft_memcpy.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_memmove.o
Normal file
BIN
libftx/libft/ft_memmove.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_memset.o
Normal file
BIN
libftx/libft/ft_memset.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_putchar_fd.o
Normal file
BIN
libftx/libft/ft_putchar_fd.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_putendl_fd.o
Normal file
BIN
libftx/libft/ft_putendl_fd.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_putnbr_fd.o
Normal file
BIN
libftx/libft/ft_putnbr_fd.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_putstr_fd.o
Normal file
BIN
libftx/libft/ft_putstr_fd.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_split.o
Normal file
BIN
libftx/libft/ft_split.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_strchr.o
Normal file
BIN
libftx/libft/ft_strchr.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_strdup.o
Normal file
BIN
libftx/libft/ft_strdup.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_striteri.o
Normal file
BIN
libftx/libft/ft_striteri.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_strjoin.o
Normal file
BIN
libftx/libft/ft_strjoin.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_strlcat.o
Normal file
BIN
libftx/libft/ft_strlcat.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_strlcpy.o
Normal file
BIN
libftx/libft/ft_strlcpy.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_strlen.o
Normal file
BIN
libftx/libft/ft_strlen.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_strmapi.o
Normal file
BIN
libftx/libft/ft_strmapi.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_strncmp.o
Normal file
BIN
libftx/libft/ft_strncmp.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_strnstr.o
Normal file
BIN
libftx/libft/ft_strnstr.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_strrchr.o
Normal file
BIN
libftx/libft/ft_strrchr.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_strtrim.o
Normal file
BIN
libftx/libft/ft_strtrim.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_substr.o
Normal file
BIN
libftx/libft/ft_substr.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_tolower.o
Normal file
BIN
libftx/libft/ft_tolower.o
Normal file
Binary file not shown.
BIN
libftx/libft/ft_toupper.o
Normal file
BIN
libftx/libft/ft_toupper.o
Normal file
Binary file not shown.
BIN
libftx/libft/libft.a
Normal file
BIN
libftx/libft/libft.a
Normal file
Binary file not shown.
BIN
libftx/libftx.a
Normal file
BIN
libftx/libftx.a
Normal file
Binary file not shown.
BIN
libftx/printf/ft_dprintX.o
Normal file
BIN
libftx/printf/ft_dprintX.o
Normal file
Binary file not shown.
BIN
libftx/printf/ft_dprintarg.o
Normal file
BIN
libftx/printf/ft_dprintarg.o
Normal file
Binary file not shown.
BIN
libftx/printf/ft_dprintflag.o
Normal file
BIN
libftx/printf/ft_dprintflag.o
Normal file
Binary file not shown.
BIN
libftx/printf/ft_dprintl_base.o
Normal file
BIN
libftx/printf/ft_dprintl_base.o
Normal file
Binary file not shown.
BIN
libftx/printf/ft_dprintptr.o
Normal file
BIN
libftx/printf/ft_dprintptr.o
Normal file
Binary file not shown.
BIN
libftx/printf/ft_dprintstrtab.o
Normal file
BIN
libftx/printf/ft_dprintstrtab.o
Normal file
Binary file not shown.
BIN
libftx/printf/ft_dprintul.o
Normal file
BIN
libftx/printf/ft_dprintul.o
Normal file
Binary file not shown.
BIN
libftx/printf/ft_dprintul_base.o
Normal file
BIN
libftx/printf/ft_dprintul_base.o
Normal file
Binary file not shown.
BIN
libftx/printf/ft_dprintx.o
Normal file
BIN
libftx/printf/ft_dprintx.o
Normal file
Binary file not shown.
BIN
libftx/printf/ft_eprintf.o
Normal file
BIN
libftx/printf/ft_eprintf.o
Normal file
Binary file not shown.
BIN
libftx/printf/ft_isarg.o
Normal file
BIN
libftx/printf/ft_isarg.o
Normal file
Binary file not shown.
BIN
libftx/printf/ft_isdigit.o
Normal file
BIN
libftx/printf/ft_isdigit.o
Normal file
Binary file not shown.
BIN
libftx/printf/ft_printf.a
Normal file
BIN
libftx/printf/ft_printf.a
Normal file
Binary file not shown.
BIN
libftx/printf/ft_printf.o
Normal file
BIN
libftx/printf/ft_printf.o
Normal file
Binary file not shown.
BIN
libftx/printf/ft_putchar_fd.o
Normal file
BIN
libftx/printf/ft_putchar_fd.o
Normal file
Binary file not shown.
BIN
libftx/printf/ft_putstr_fd.o
Normal file
BIN
libftx/printf/ft_putstr_fd.o
Normal file
Binary file not shown.
BIN
libftx/printf/ft_skipflag.o
Normal file
BIN
libftx/printf/ft_skipflag.o
Normal file
Binary file not shown.
BIN
libftx/printf/ft_strlen.o
Normal file
BIN
libftx/printf/ft_strlen.o
Normal file
Binary file not shown.
BIN
libftx/printf/ft_vdprintf.o
Normal file
BIN
libftx/printf/ft_vdprintf.o
Normal file
Binary file not shown.
8
main.c
8
main.c
@ -6,10 +6,10 @@ void ft_lstdel(void *ptr)
|
|||||||
t_cmd *content;
|
t_cmd *content;
|
||||||
|
|
||||||
content = (t_cmd *) ptr;
|
content = (t_cmd *) ptr;
|
||||||
if (content->executable != NULL)
|
|
||||||
free(content->executable);
|
|
||||||
if (content->args != NULL)
|
if (content->args != NULL)
|
||||||
ft_freer_tab_ultimate(1, content->args);
|
ft_freer_tab_ultimate(1, content->args);
|
||||||
|
if (content->executable != NULL)
|
||||||
|
free(content->executable);
|
||||||
free(content);
|
free(content);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,6 +132,7 @@ int ft_cmd_filler(t_list *element, char **args)
|
|||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
content->args = args;
|
content->args = args;
|
||||||
|
//pas free:10
|
||||||
content->executable = args[0];
|
content->executable = args[0];
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
@ -179,7 +180,6 @@ t_list **ft_parse_cmds(char *line)
|
|||||||
return (NULL);
|
return (NULL);
|
||||||
if (ft_cmds_fill(cmds, line) == 1)
|
if (ft_cmds_fill(cmds, line) == 1)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
ft_printf("%s\n", line);
|
|
||||||
return (cmds);
|
return (cmds);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -204,5 +204,7 @@ int main(int ac, char **av, char **env)
|
|||||||
}
|
}
|
||||||
ft_lstclear(data.env, env_del);
|
ft_lstclear(data.env, env_del);
|
||||||
ft_lstclear(cmds, ft_lstdel);
|
ft_lstclear(cmds, ft_lstdel);
|
||||||
|
free(cmds);
|
||||||
|
free(data.env);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
13
minishell.h
13
minishell.h
@ -1,3 +1,15 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* minishell.h :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2023/02/14 13:45:30 by cchauvet #+# #+# */
|
||||||
|
/* Updated: 2023/02/14 14:54:25 by cchauvet ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#ifndef MINISHELL_H
|
#ifndef MINISHELL_H
|
||||||
# define MINISHELL_H
|
# define MINISHELL_H
|
||||||
# include "libftx/libftx.h"
|
# include "libftx/libftx.h"
|
||||||
@ -24,6 +36,7 @@ int ft_heredoc(char *stop);
|
|||||||
size_t ft_seglen_quoted(const char *str, char c);
|
size_t ft_seglen_quoted(const char *str, char c);
|
||||||
int ft_cmds_executor(t_list **cmds, char **env);
|
int ft_cmds_executor(t_list **cmds, char **env);
|
||||||
char **ft_split_quoted(const char *s, char c);
|
char **ft_split_quoted(const char *s, char c);
|
||||||
|
void env_del(void *content);
|
||||||
|
|
||||||
typedef struct s_cmd
|
typedef struct s_cmd
|
||||||
{
|
{
|
||||||
|
@ -46,6 +46,8 @@ static int ft_pipe_is_alone(const char *str)
|
|||||||
return (0);
|
return (0);
|
||||||
i--;
|
i--;
|
||||||
}
|
}
|
||||||
|
if (i == 0)
|
||||||
|
return (0);
|
||||||
ft_eprintf("minishell: Pipe must be followed by a command or redirection\n");
|
ft_eprintf("minishell: Pipe must be followed by a command or redirection\n");
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
BIN
syntatics.o
Normal file
BIN
syntatics.o
Normal file
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user