kill me
This commit is contained in:
3
Makefile
3
Makefile
@ -6,7 +6,7 @@
|
||||
# By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ #
|
||||
# +#+#+#+#+#+ +#+ #
|
||||
# Created: 2023/07/28 00:35:01 by tomoron #+# #+# #
|
||||
# Updated: 2024/05/06 11:00:33 by tomoron ### ########.fr #
|
||||
# Updated: 2024/05/22 13:50:22 by tomoron ### ########.fr #
|
||||
# #
|
||||
# **************************************************************************** #
|
||||
|
||||
@ -46,6 +46,7 @@ SRCS_RAW = main.c\
|
||||
get_len_bonus.c\
|
||||
check_syntax.c\
|
||||
check_syntax_utils.c\
|
||||
parsing_utils.c\
|
||||
unset.c\
|
||||
free.c
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/03/24 17:44:32 by marde-vr #+# #+# */
|
||||
/* Updated: 2024/05/06 15:09:44 by tomoron ### ########.fr */
|
||||
/* Updated: 2024/05/22 13:48:39 by tomoron ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -27,7 +27,7 @@ void get_here_doc_input(t_msh *msh, char *eof)
|
||||
ft_printf_fd(2, " end-of-file, (wanted `%s')\n", eof);
|
||||
break ;
|
||||
}
|
||||
if (line && !ft_strncmp(line, eof, ft_strlen(eof)))
|
||||
if (line && !ft_strcmp(line, eof))
|
||||
break ;
|
||||
parse_var(msh, line);
|
||||
write(msh->in_fd, "\n", 1);
|
||||
@ -58,7 +58,8 @@ void here_doc_signal(t_msh *msh, int child_pid, char *here_doc_file)
|
||||
set_echoctl(msh->echoctl);
|
||||
signal(SIGINT, signal_handler_interactive);
|
||||
signal(SIGQUIT, signal_handler_interactive);
|
||||
close(msh->in_fd);
|
||||
if (msh->in_fd > 2)
|
||||
close(msh->in_fd);
|
||||
if (WIFEXITED(status) && WEXITSTATUS(status))
|
||||
{
|
||||
unlink(here_doc_file);
|
||||
@ -79,7 +80,8 @@ void handle_here_doc(t_msh *msh, char *eof)
|
||||
here_doc_file = get_tmp_file_name(msh);
|
||||
if (msh->here_doc_filename)
|
||||
{
|
||||
close(msh->in_fd);
|
||||
if (msh->in_fd)
|
||||
close(msh->in_fd);
|
||||
unlink(msh->here_doc_filename);
|
||||
free(msh->here_doc_filename);
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/02/04 17:31:38 by tomoron #+# #+# */
|
||||
/* Updated: 2024/05/16 13:21:32 by tomoron ### ########.fr */
|
||||
/* Updated: 2024/05/22 13:49:58 by tomoron ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -165,6 +165,7 @@ char *get_var_name(char *str);
|
||||
int exec_builtin(t_msh *msh);
|
||||
void get_cmd_path(t_msh *msh);
|
||||
int is_cmd_type(t_cmd *cmd);
|
||||
int get_home_var_len(void);
|
||||
int set_echoctl(int value);
|
||||
int print_env(t_env *env);
|
||||
t_cmd *free_cmd(t_cmd *cmd);
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/02/09 15:26:01 by tomoron #+# #+# */
|
||||
/* Updated: 2024/05/06 16:26:35 by tomoron ### ########.fr */
|
||||
/* Updated: 2024/05/22 13:52:40 by tomoron ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
#include "minishell.h"
|
||||
@ -18,11 +18,16 @@ int add_home_to_str(char *res)
|
||||
|
||||
i = 0;
|
||||
str = getenv("HOME");
|
||||
while (str[i])
|
||||
while (str && str[i])
|
||||
{
|
||||
res[i] = str[i];
|
||||
i++;
|
||||
}
|
||||
if (!str)
|
||||
{
|
||||
res[i] = '~';
|
||||
return (1);
|
||||
}
|
||||
return (i);
|
||||
}
|
||||
|
||||
|
24
srcs/parsing_utils.c
Normal file
24
srcs/parsing_utils.c
Normal file
@ -0,0 +1,24 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* parsing_utils.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: tomoron <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/22 13:49:17 by tomoron #+# #+# */
|
||||
/* Updated: 2024/05/22 13:50:31 by tomoron ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "minishell.h"
|
||||
|
||||
int get_home_var_len(void)
|
||||
{
|
||||
char *str;
|
||||
|
||||
str = getenv("HOME");
|
||||
if (!str)
|
||||
return (1);
|
||||
else
|
||||
return (ft_strlen("HOME"));
|
||||
}
|
@ -6,7 +6,7 @@
|
||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/02/09 15:24:36 by tomoron #+# #+# */
|
||||
/* Updated: 2024/05/08 11:59:25 by tomoron ### ########.fr */
|
||||
/* Updated: 2024/05/22 13:52:29 by tomoron ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -67,7 +67,7 @@ int get_token_len(char *command)
|
||||
if (*command == '\'' && !in_dquote)
|
||||
in_quote = !in_quote;
|
||||
else if (*command == '~' && !in_quote && !in_dquote)
|
||||
res += ft_strlen(getenv("HOME"));
|
||||
res += get_home_var_len();
|
||||
else if (*command != '\'' && *command != '"')
|
||||
res++;
|
||||
else if ((*command == '\'' && in_dquote) || (*command == '"'
|
||||
|
Reference in New Issue
Block a user