chepa, des trucs, regarde le commit si tu veut savoir
This commit is contained in:
13
Makefile
13
Makefile
@ -6,7 +6,7 @@
|
|||||||
# By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ #
|
# By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ #
|
||||||
# +#+#+#+#+#+ +#+ #
|
# +#+#+#+#+#+ +#+ #
|
||||||
# Created: 2023/07/28 00:35:01 by tomoron #+# #+# #
|
# Created: 2023/07/28 00:35:01 by tomoron #+# #+# #
|
||||||
# Updated: 2024/04/01 20:09:57 by marde-vr ### ########.fr #
|
# Updated: 2024/04/02 16:07:12 by tomoron ### ########.fr #
|
||||||
# #
|
# #
|
||||||
# **************************************************************************** #
|
# **************************************************************************** #
|
||||||
|
|
||||||
@ -53,16 +53,19 @@ all:
|
|||||||
@$(MAKE) --no-print-directory -j $(NAME)
|
@$(MAKE) --no-print-directory -j $(NAME)
|
||||||
|
|
||||||
$(NAME) : $(LIBFT) $(OBJS)
|
$(NAME) : $(LIBFT) $(OBJS)
|
||||||
$(CC) $(FLAGS) $(OBJS) $(LIBFT) -lreadline -o $(NAME)
|
@$(CC) $(FLAGS) $(OBJS) $(LIBFT) -lreadline -o $(NAME)
|
||||||
|
@echo project ready
|
||||||
|
|
||||||
$(LIBFT):
|
$(LIBFT):
|
||||||
make --no-print-directory -j -C ./libft
|
@echo compiling libft...
|
||||||
|
@make --no-print-directory -j -C ./libft
|
||||||
|
@echo done
|
||||||
|
|
||||||
$(OBJS_DIR):
|
$(OBJS_DIR):
|
||||||
mkdir -p $(OBJS_DIR)
|
@mkdir -p $(OBJS_DIR)
|
||||||
|
|
||||||
$(OBJS_DIR)%.o : $(SRCS_DIR)%.c | $(OBJS_DIR)
|
$(OBJS_DIR)%.o : $(SRCS_DIR)%.c | $(OBJS_DIR)
|
||||||
$(CC) $(FLAGS) -c $< -o $@
|
@$(CC) $(FLAGS) -c $< -o $@
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf $(OBJS_DIR)
|
rm -rf $(OBJS_DIR)
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
# By: tomoron <marvin@42.fr> +#+ +:+ +#+ #
|
# By: tomoron <marvin@42.fr> +#+ +:+ +#+ #
|
||||||
# +#+#+#+#+#+ +#+ #
|
# +#+#+#+#+#+ +#+ #
|
||||||
# Created: 2023/07/28 00:35:01 by tomoron #+# #+# #
|
# Created: 2023/07/28 00:35:01 by tomoron #+# #+# #
|
||||||
# Updated: 2024/02/11 17:41:50 by tomoron ### ########.fr #
|
# Updated: 2024/04/02 16:02:33 by tomoron ### ########.fr #
|
||||||
# #
|
# #
|
||||||
# **************************************************************************** #
|
# **************************************************************************** #
|
||||||
|
|
||||||
@ -73,14 +73,14 @@ all: $(NAME)
|
|||||||
|
|
||||||
|
|
||||||
$(NAME): ft_printf $(OBJS)
|
$(NAME): ft_printf $(OBJS)
|
||||||
make --no-print-directory -C ./ft_printf
|
@make --no-print-directory -C ./ft_printf
|
||||||
cp ./ft_printf/libftprintf.a ./gnl/gnl.a
|
@cp ./ft_printf/libftprintf.a ./gnl/gnl.a
|
||||||
make --no-print-directory -C ./gnl
|
@make --no-print-directory -C ./gnl
|
||||||
cp ./gnl/gnl.a ./$(NAME)
|
@cp ./gnl/gnl.a ./$(NAME)
|
||||||
ar rcs $(NAME) $(OBJS)
|
@ar rcs $(NAME) $(OBJS)
|
||||||
|
|
||||||
.c.o:
|
.c.o:
|
||||||
$(CC) $(FLAGS) -c $< -o $@
|
@$(CC) $(FLAGS) -c $< -o $@
|
||||||
|
|
||||||
bonus: $(OBJS) $(OBJS_BONUS)
|
bonus: $(OBJS) $(OBJS_BONUS)
|
||||||
ar rcs $(NAME) $(OBJS) $(OBJS_BONUS)
|
ar rcs $(NAME) $(OBJS) $(OBJS_BONUS)
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
# By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ #
|
# By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ #
|
||||||
# +#+#+#+#+#+ +#+ #
|
# +#+#+#+#+#+ +#+ #
|
||||||
# Created: 2023/11/04 08:03:00 by tomoron #+# #+# #
|
# Created: 2023/11/04 08:03:00 by tomoron #+# #+# #
|
||||||
# Updated: 2024/02/16 14:22:14 by marde-vr ### ########.fr #
|
# Updated: 2024/04/02 16:02:53 by tomoron ### ########.fr #
|
||||||
# #
|
# #
|
||||||
# **************************************************************************** #
|
# **************************************************************************** #
|
||||||
|
|
||||||
@ -34,10 +34,10 @@ OBJS = $(SRCS:.c=.o)
|
|||||||
FLAGS = -Wall -Wextra -Werror
|
FLAGS = -Wall -Wextra -Werror
|
||||||
|
|
||||||
$(NAME): $(OBJS)
|
$(NAME): $(OBJS)
|
||||||
ar rcs $(NAME) $(OBJS)
|
@ar rcs $(NAME) $(OBJS)
|
||||||
|
|
||||||
.c.o:
|
.c.o:
|
||||||
$(CC) $(FLAGS) -c $< -o $@
|
@$(CC) $(FLAGS) -c $< -o $@
|
||||||
|
|
||||||
all: $(NAME)
|
all: $(NAME)
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
# By: tomoron <marvin@42.fr> +#+ +:+ +#+ #
|
# By: tomoron <marvin@42.fr> +#+ +:+ +#+ #
|
||||||
# +#+#+#+#+#+ +#+ #
|
# +#+#+#+#+#+ +#+ #
|
||||||
# Created: 2023/11/04 08:03:00 by tomoron #+# #+# #
|
# Created: 2023/11/04 08:03:00 by tomoron #+# #+# #
|
||||||
# Updated: 2023/12/04 09:49:24 by tomoron ### ########.fr #
|
# Updated: 2024/04/02 16:03:57 by tomoron ### ########.fr #
|
||||||
# #
|
# #
|
||||||
# **************************************************************************** #
|
# **************************************************************************** #
|
||||||
|
|
||||||
@ -22,10 +22,10 @@ OBJS = $(SRCS:.c=.o)
|
|||||||
FLAGS = -Wall -Wextra -Werror
|
FLAGS = -Wall -Wextra -Werror
|
||||||
|
|
||||||
$(NAME): $(OBJS)
|
$(NAME): $(OBJS)
|
||||||
ar rcs $(NAME) $(OBJS)
|
@ar rcs $(NAME) $(OBJS)
|
||||||
|
|
||||||
.c.o:
|
.c.o:
|
||||||
$(CC) $(FLAGS) -c $< -o $@
|
@$(CC) $(FLAGS) -c $< -o $@
|
||||||
|
|
||||||
all: $(NAME)
|
all: $(NAME)
|
||||||
|
|
||||||
|
10
srcs/debug.c
10
srcs/debug.c
@ -6,7 +6,7 @@
|
|||||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/02/18 15:46:50 by tomoron #+# #+# */
|
/* Created: 2024/02/18 15:46:50 by tomoron #+# #+# */
|
||||||
/* Updated: 2024/04/02 13:34:10 by tomoron ### ########.fr */
|
/* Updated: 2024/04/02 15:04:59 by tomoron ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -36,6 +36,14 @@ void print_parsed_cmd(t_cmd *cmd)
|
|||||||
printf("[OR] ");
|
printf("[OR] ");
|
||||||
if(cmd->cmd_type == PIPE)
|
if(cmd->cmd_type == PIPE)
|
||||||
printf("[PIPE] ");
|
printf("[PIPE] ");
|
||||||
|
if(cmd->cmd_type == RED_O_APP)
|
||||||
|
printf("[RED_O_APP : %s] ", cmd->value);
|
||||||
|
if(cmd->cmd_type == RED_O)
|
||||||
|
printf("[RED_O : %s] ", cmd->value);
|
||||||
|
if(cmd->cmd_type == RED_I)
|
||||||
|
printf("[RED_I : %s] ", cmd->value);
|
||||||
|
if(cmd->cmd_type == HERE_DOC)
|
||||||
|
printf("[HERE_DOC : %s] ", cmd->value);
|
||||||
cmd = cmd->next;
|
cmd = cmd->next;
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/03/28 13:50:14 by tomoron #+# #+# */
|
/* Created: 2024/03/28 13:50:14 by tomoron #+# #+# */
|
||||||
/* Updated: 2024/04/02 13:51:42 by tomoron ### ########.fr */
|
/* Updated: 2024/04/02 15:03:01 by tomoron ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -48,10 +48,10 @@ void exec_command_bonus(t_msh *msh, char *cmd_str)
|
|||||||
if (cmds->cmd_type == CMD)
|
if (cmds->cmd_type == CMD)
|
||||||
{
|
{
|
||||||
msh->cmds = parse_command(cmds->value, msh->env);
|
msh->cmds = parse_command(cmds->value, msh->env);
|
||||||
get_redirections(msh, cmds);
|
// get_redirections(msh, cmds);
|
||||||
print_parsed_cmd(cmds);
|
print_parsed_cmd(cmds);
|
||||||
print_parsed_token(msh->cmds);
|
print_parsed_token(msh->cmds);
|
||||||
exec_commands(msh);
|
// exec_commands(msh);
|
||||||
}
|
}
|
||||||
cmds = cmds->next;
|
cmds = cmds->next;
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/02/04 17:31:38 by tomoron #+# #+# */
|
/* Created: 2024/02/04 17:31:38 by tomoron #+# #+# */
|
||||||
/* Updated: 2024/04/02 02:07:36 by tomoron ### ########.fr */
|
/* Updated: 2024/04/02 14:49:11 by tomoron ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -117,7 +117,6 @@ int first_is_in_type(t_cmd *cmd);
|
|||||||
int contains_newline(char *str);
|
int contains_newline(char *str);
|
||||||
int check_var_name(char *name);
|
int check_var_name(char *name);
|
||||||
char **get_cmd_args(t_msh *msh);
|
char **get_cmd_args(t_msh *msh);
|
||||||
void exec_commands(t_msh *msh);
|
|
||||||
char *remove_path(char *token);
|
char *remove_path(char *token);
|
||||||
char *get_var_name(char *str);
|
char *get_var_name(char *str);
|
||||||
int exec_builtin(t_msh *msh);
|
int exec_builtin(t_msh *msh);
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: tomoron <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: tomoron <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/03/27 14:40:44 by tomoron #+# #+# */
|
/* Created: 2024/03/27 14:40:44 by tomoron #+# #+# */
|
||||||
/* Updated: 2024/04/02 13:41:32 by tomoron ### ########.fr */
|
/* Updated: 2024/04/02 15:17:30 by tomoron ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -32,7 +32,7 @@ int check_str_syntax(char *cmd)
|
|||||||
cmd++;
|
cmd++;
|
||||||
}
|
}
|
||||||
if (in_quote || in_dquote || parenthesis)
|
if (in_quote || in_dquote || parenthesis)
|
||||||
ft_putstr_fd("minishell: syntax error", 2);
|
ft_putstr_fd("minishell: syntax error\n", 2);
|
||||||
return (!(in_quote || in_dquote || parenthesis));
|
return (!(in_quote || in_dquote || parenthesis));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,7 +145,7 @@ t_cmd *check_cmds_syntax(t_cmd *cmds)
|
|||||||
t_cmd_type last;
|
t_cmd_type last;
|
||||||
t_token *token;
|
t_token *token;
|
||||||
|
|
||||||
if (cmds->cmd_type == OR || cmds->cmd_type == AND || cmds->cmd_type == PIPE)
|
if (!cmds || cmds->cmd_type == OR || cmds->cmd_type == AND || cmds->cmd_type == PIPE)
|
||||||
return (cmds);
|
return (cmds);
|
||||||
last = cmds->cmd_type;
|
last = cmds->cmd_type;
|
||||||
cmds = cmds->next;
|
cmds = cmds->next;
|
||||||
@ -153,8 +153,7 @@ t_cmd *check_cmds_syntax(t_cmd *cmds)
|
|||||||
{
|
{
|
||||||
if (cmds->cmd_type == OR || cmds->cmd_type == AND
|
if (cmds->cmd_type == OR || cmds->cmd_type == AND
|
||||||
|| cmds->cmd_type == PIPE)
|
|| cmds->cmd_type == PIPE)
|
||||||
if ((last != CMD && last != PAREN) || (!cmds->next
|
if ((last != CMD && last != PAREN) || !cmds->next || (cmds->next->cmd_type != CMD
|
||||||
&& cmds->next->cmd_type != CMD
|
|
||||||
&& cmds->next->cmd_type != PAREN))
|
&& cmds->next->cmd_type != PAREN))
|
||||||
return (cmds);
|
return (cmds);
|
||||||
if (cmds->cmd_type == CMD || cmds->cmd_type == PAREN)
|
if (cmds->cmd_type == CMD || cmds->cmd_type == PAREN)
|
||||||
@ -169,6 +168,42 @@ t_cmd *check_cmds_syntax(t_cmd *cmds)
|
|||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int get_next_arg_len(char *cmd)
|
||||||
|
{
|
||||||
|
int len;
|
||||||
|
int in_quote;
|
||||||
|
int in_dquote;
|
||||||
|
|
||||||
|
len = 0;
|
||||||
|
in_quote = 0;
|
||||||
|
in_dquote = 0;
|
||||||
|
while (cmd[len] && ((!ft_isspace(cmd[len]) && cmd[len] != '&'
|
||||||
|
&& cmd[len] != '|' && cmd[len] != '<' && cmd[len] != '>')
|
||||||
|
|| in_quote || in_dquote))
|
||||||
|
{
|
||||||
|
if (cmd[len] == '\'' && !in_dquote)
|
||||||
|
in_quote = !in_quote;
|
||||||
|
if (cmd[len] == '"' && !in_quote)
|
||||||
|
in_dquote = !in_dquote;
|
||||||
|
len++;
|
||||||
|
}
|
||||||
|
return(len);
|
||||||
|
}
|
||||||
|
char *get_next_arg(char **cmd)
|
||||||
|
{
|
||||||
|
int len;
|
||||||
|
char *res;
|
||||||
|
|
||||||
|
while(ft_isspace(**cmd))
|
||||||
|
(*cmd)++;
|
||||||
|
len = get_next_arg_len(*cmd);
|
||||||
|
if(!len)
|
||||||
|
return(0);
|
||||||
|
res = ft_substr(*cmd, 0, len);
|
||||||
|
*cmd += len;
|
||||||
|
return (res);
|
||||||
|
}
|
||||||
|
|
||||||
t_cmd *parsing_bonus(char *cmd)
|
t_cmd *parsing_bonus(char *cmd)
|
||||||
{
|
{
|
||||||
t_cmd *res;
|
t_cmd *res;
|
||||||
@ -185,8 +220,9 @@ t_cmd *parsing_bonus(char *cmd)
|
|||||||
type = get_cmd_type_bonus(&cmd);
|
type = get_cmd_type_bonus(&cmd);
|
||||||
if (type == CMD || type == PAREN)
|
if (type == CMD || type == PAREN)
|
||||||
value = get_cmd_value(&cmd, type);
|
value = get_cmd_value(&cmd, type);
|
||||||
else if (type == RED_O || type == RED_O_APP)
|
else if (type == RED_O || type == RED_O_APP || type == RED_I
|
||||||
value = 0; // TODO: set value to the next argument
|
|| type == HERE_DOC)
|
||||||
|
value = get_next_arg(&cmd);
|
||||||
else
|
else
|
||||||
value = 0;
|
value = 0;
|
||||||
res = cmd_add_back(res, value, type);
|
res = cmd_add_back(res, value, type);
|
||||||
|
Reference in New Issue
Block a user