mirror of
https://github.com/KeyZox71/ft_minipowershell.git
synced 2025-03-15 03:16:51 +01:00
「✨」 feat: Added ctrl c to heredoc
This commit is contained in:
@ -6,7 +6,7 @@
|
||||
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/29 13:20:22 by mmoussou #+# #+# */
|
||||
/* Updated: 2024/07/10 01:21:10 by adjoly ### ########.fr */
|
||||
/* Updated: 2024/07/13 14:03:47 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -47,5 +47,9 @@ void __close(void *content);
|
||||
int ft_heredoc(char *delimiter, t_cmd *cmd);
|
||||
int __open_fd_here(char *path, int mode);
|
||||
void ft_lstclear_till_nxt(t_list **lst, void (*del)(void *));
|
||||
int get_fd_heredoc(int in);
|
||||
int check_error(int heredoc_ret, int fd);
|
||||
void __heredoc_sig(int code);
|
||||
int fd_manager(int mode);
|
||||
|
||||
#endif
|
||||
|
@ -42,5 +42,6 @@ void free_cmd(void *content);
|
||||
t_env **get_env(t_env **env);
|
||||
t_list **get_list(t_list **list);
|
||||
t_list **get_list2(t_list **list);
|
||||
int get_exit_code(int in);
|
||||
|
||||
#endif
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/25 12:20:26 by adjoly #+# #+# */
|
||||
/* Updated: 2024/07/09 23:52:39 by adjoly ### ########.fr */
|
||||
/* Updated: 2024/07/10 14:13:41 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -48,7 +48,6 @@ void open_redir(t_redirection *redir, t_cmd *cmd, t_redir_sign sign[2]);
|
||||
*/
|
||||
size_t strlen_till_char(char *s, int c);
|
||||
|
||||
|
||||
bool check_quote(char *readline);
|
||||
bool check_syntax(char *readline);
|
||||
bool check_redir(t_list *redir);
|
||||
|
57
minishell.supp
Normal file
57
minishell.supp
Normal file
@ -0,0 +1,57 @@
|
||||
{
|
||||
readline
|
||||
Memcheck:Leak
|
||||
match-leak-kinds: reachable
|
||||
...
|
||||
fun:readline
|
||||
...
|
||||
}
|
||||
{
|
||||
readline-history
|
||||
Memcheck:Leak
|
||||
...
|
||||
fun:xmalloc
|
||||
fun:add_history
|
||||
...
|
||||
}
|
||||
{
|
||||
</bin/toe>
|
||||
Memcheck:Leak
|
||||
match-leak-kinds: reachable
|
||||
...
|
||||
obj:/usr/bin/toe
|
||||
fun:(below main)
|
||||
}
|
||||
{
|
||||
</bin/locale>
|
||||
Memcheck:Leak
|
||||
...
|
||||
obj:/usr/bin/locale
|
||||
fun:(below main)
|
||||
}
|
||||
{
|
||||
</bin/clear>
|
||||
Memcheck:Leak
|
||||
match-leak-kinds: reachable
|
||||
...
|
||||
obj:/usr/bin/clear
|
||||
fun:(below main)
|
||||
}
|
||||
{
|
||||
</bin/cat>
|
||||
Memcheck:Leak
|
||||
...
|
||||
obj:/usr/bin/cat
|
||||
fun:(below main)
|
||||
}
|
||||
{
|
||||
</bin/ls>
|
||||
Memcheck:Leak
|
||||
...
|
||||
obj:/usr/bin/ls
|
||||
fun:(below main)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,493 +0,0 @@
|
||||
{
|
||||
<insert_a_suppression_name_here>
|
||||
Memcheck:Leak
|
||||
match-leak-kinds: reachable
|
||||
fun:malloc
|
||||
fun:xmalloc
|
||||
fun:alloc_history_entry
|
||||
fun:add_history
|
||||
fun:main
|
||||
}
|
||||
{
|
||||
<insert_a_suppression_name_here>
|
||||
Memcheck:Leak
|
||||
match-leak-kinds: definite
|
||||
fun:malloc
|
||||
fun:xmalloc
|
||||
fun:readline_internal_teardown
|
||||
fun:readline
|
||||
fun:main
|
||||
}
|
||||
{
|
||||
<insert_a_suppression_name_here>
|
||||
Memcheck:Leak
|
||||
match-leak-kinds: reachable
|
||||
fun:realloc
|
||||
fun:_nc_doalloc
|
||||
fun:_nc_tiparm
|
||||
obj:/usr/lib/x86_64-linux-gnu/libtinfo.so.6.3
|
||||
fun:_nc_trim_sgr0
|
||||
fun:tgetent_sp
|
||||
fun:_rl_init_terminal_io
|
||||
fun:rl_initialize
|
||||
fun:readline
|
||||
fun:main
|
||||
}
|
||||
{
|
||||
<insert_a_suppression_name_here>
|
||||
Memcheck:Leak
|
||||
match-leak-kinds: reachable
|
||||
fun:malloc
|
||||
fun:strdup
|
||||
fun:_nc_trim_sgr0
|
||||
fun:tgetent_sp
|
||||
fun:_rl_init_terminal_io
|
||||
fun:rl_initialize
|
||||
fun:readline
|
||||
fun:main
|
||||
}
|
||||
{
|
||||
<insert_a_suppression_name_here>
|
||||
Memcheck:Leak
|
||||
match-leak-kinds: reachable
|
||||
fun:malloc
|
||||
fun:xrealloc
|
||||
obj:/usr/lib/x86_64-linux-gnu/libreadline.so.8.1
|
||||
fun:rl_expand_prompt
|
||||
fun:rl_set_prompt
|
||||
fun:readline
|
||||
fun:main
|
||||
}
|
||||
{
|
||||
<insert_a_suppression_name_here>
|
||||
Memcheck:Leak
|
||||
match-leak-kinds: reachable
|
||||
fun:malloc
|
||||
fun:xmalloc
|
||||
fun:add_history
|
||||
fun:main
|
||||
}
|
||||
{
|
||||
<insert_a_suppression_name_here>
|
||||
Memcheck:Leak
|
||||
match-leak-kinds: reachable
|
||||
fun:malloc
|
||||
fun:xmalloc
|
||||
obj:/usr/lib/x86_64-linux-gnu/libreadline.so.8.1
|
||||
fun:rl_initialize
|
||||
fun:readline
|
||||
fun:main
|
||||
}
|
||||
{
|
||||
<insert_a_suppression_name_here>
|
||||
Memcheck:Leak
|
||||
match-leak-kinds: reachable
|
||||
fun:malloc
|
||||
fun:strdup
|
||||
fun:_nc_setupterm
|
||||
fun:tgetent_sp
|
||||
fun:_rl_init_terminal_io
|
||||
fun:rl_initialize
|
||||
fun:readline
|
||||
fun:main
|
||||
}
|
||||
{
|
||||
<insert_a_suppression_name_here>
|
||||
Memcheck:Leak
|
||||
match-leak-kinds: reachable
|
||||
fun:malloc
|
||||
fun:rl_initialize
|
||||
fun:readline
|
||||
fun:main
|
||||
}
|
||||
{
|
||||
<insert_a_suppression_name_here>
|
||||
Memcheck:Leak
|
||||
match-leak-kinds: reachable
|
||||
fun:malloc
|
||||
fun:strdup
|
||||
obj:/usr/lib/x86_64-linux-gnu/libtinfo.so.6.3
|
||||
fun:_nc_first_db
|
||||
fun:_nc_read_entry2
|
||||
obj:/usr/lib/x86_64-linux-gnu/libtinfo.so.6.3
|
||||
fun:_nc_setupterm
|
||||
fun:tgetent_sp
|
||||
fun:_rl_init_terminal_io
|
||||
fun:rl_initialize
|
||||
fun:readline
|
||||
fun:main
|
||||
}
|
||||
{
|
||||
<insert_a_suppression_name_here>
|
||||
Memcheck:Leak
|
||||
match-leak-kinds: reachable
|
||||
fun:malloc
|
||||
fun:xmalloc
|
||||
obj:/usr/lib/x86_64-linux-gnu/libreadline.so.8.1
|
||||
fun:rl_parse_and_bind
|
||||
obj:/usr/lib/x86_64-linux-gnu/libreadline.so.8.1
|
||||
fun:rl_initialize
|
||||
fun:readline
|
||||
fun:main
|
||||
}
|
||||
{
|
||||
<insert_a_suppression_name_here>
|
||||
Memcheck:Leak
|
||||
match-leak-kinds: reachable
|
||||
fun:malloc
|
||||
fun:tsearch
|
||||
obj:/usr/lib/x86_64-linux-gnu/libtinfo.so.6.3
|
||||
fun:_nc_tiparm
|
||||
obj:/usr/lib/x86_64-linux-gnu/libtinfo.so.6.3
|
||||
fun:_nc_trim_sgr0
|
||||
fun:tgetent_sp
|
||||
fun:_rl_init_terminal_io
|
||||
fun:rl_initialize
|
||||
fun:readline
|
||||
fun:main
|
||||
}
|
||||
{
|
||||
<insert_a_suppression_name_here>
|
||||
Memcheck:Leak
|
||||
match-leak-kinds: reachable
|
||||
fun:malloc
|
||||
fun:_nc_home_terminfo
|
||||
fun:_nc_first_db
|
||||
fun:_nc_read_entry2
|
||||
obj:/usr/lib/x86_64-linux-gnu/libtinfo.so.6.3
|
||||
fun:_nc_setupterm
|
||||
fun:tgetent_sp
|
||||
fun:_rl_init_terminal_io
|
||||
fun:rl_initialize
|
||||
fun:readline
|
||||
fun:main
|
||||
}
|
||||
{
|
||||
<insert_a_suppression_name_here>
|
||||
Memcheck:Leak
|
||||
match-leak-kinds: reachable
|
||||
fun:malloc
|
||||
fun:xmalloc
|
||||
fun:rl_set_prompt
|
||||
fun:readline
|
||||
fun:main
|
||||
}
|
||||
{
|
||||
<insert_a_suppression_name_here>
|
||||
Memcheck:Leak
|
||||
match-leak-kinds: reachable
|
||||
fun:malloc
|
||||
fun:xmalloc
|
||||
obj:/usr/lib/x86_64-linux-gnu/libreadline.so.8.1
|
||||
fun:rl_expand_prompt
|
||||
fun:rl_set_prompt
|
||||
fun:readline
|
||||
fun:main
|
||||
}
|
||||
{
|
||||
<insert_a_suppression_name_here>
|
||||
Memcheck:Leak
|
||||
match-leak-kinds: reachable
|
||||
fun:realloc
|
||||
fun:_nc_doalloc
|
||||
fun:_nc_read_termtype
|
||||
obj:/usr/lib/x86_64-linux-gnu/libtinfo.so.6.3
|
||||
obj:/usr/lib/x86_64-linux-gnu/libtinfo.so.6.3
|
||||
fun:_nc_read_entry2
|
||||
obj:/usr/lib/x86_64-linux-gnu/libtinfo.so.6.3
|
||||
fun:_nc_setupterm
|
||||
fun:tgetent_sp
|
||||
fun:_rl_init_terminal_io
|
||||
fun:rl_initialize
|
||||
fun:readline
|
||||
}
|
||||
{
|
||||
<insert_a_suppression_name_here>
|
||||
Memcheck:Leak
|
||||
match-leak-kinds: reachable
|
||||
fun:malloc
|
||||
obj:/usr/lib/x86_64-linux-gnu/libtinfo.so.6.3
|
||||
fun:_nc_setupterm
|
||||
fun:tgetent_sp
|
||||
fun:_rl_init_terminal_io
|
||||
fun:rl_initialize
|
||||
fun:readline
|
||||
fun:main
|
||||
}
|
||||
{
|
||||
<insert_a_suppression_name_here>
|
||||
Memcheck:Leak
|
||||
match-leak-kinds: reachable
|
||||
fun:calloc
|
||||
fun:_nc_first_db
|
||||
fun:_nc_read_entry2
|
||||
obj:/usr/lib/x86_64-linux-gnu/libtinfo.so.6.3
|
||||
fun:_nc_setupterm
|
||||
fun:tgetent_sp
|
||||
fun:_rl_init_terminal_io
|
||||
fun:rl_initialize
|
||||
fun:readline
|
||||
fun:main
|
||||
}
|
||||
{
|
||||
<insert_a_suppression_name_here>
|
||||
Memcheck:Leak
|
||||
match-leak-kinds: reachable
|
||||
fun:malloc
|
||||
fun:strdup
|
||||
obj:/usr/lib/x86_64-linux-gnu/libtinfo.so.6.3
|
||||
fun:_nc_tiparm
|
||||
obj:/usr/lib/x86_64-linux-gnu/libtinfo.so.6.3
|
||||
fun:_nc_trim_sgr0
|
||||
fun:tgetent_sp
|
||||
fun:_rl_init_terminal_io
|
||||
fun:rl_initialize
|
||||
fun:readline
|
||||
fun:main
|
||||
}
|
||||
{
|
||||
<insert_a_suppression_name_here>
|
||||
Memcheck:Leak
|
||||
match-leak-kinds: reachable
|
||||
fun:malloc
|
||||
fun:_nc_tparm_analyze
|
||||
obj:/usr/lib/x86_64-linux-gnu/libtinfo.so.6.3
|
||||
fun:_nc_tiparm
|
||||
obj:/usr/lib/x86_64-linux-gnu/libtinfo.so.6.3
|
||||
fun:_nc_trim_sgr0
|
||||
fun:tgetent_sp
|
||||
fun:_rl_init_terminal_io
|
||||
fun:rl_initialize
|
||||
fun:readline
|
||||
fun:main
|
||||
}
|
||||
{
|
||||
<insert_a_suppression_name_here>
|
||||
Memcheck:Leak
|
||||
match-leak-kinds: reachable
|
||||
fun:malloc
|
||||
fun:_nc_first_db
|
||||
fun:_nc_read_entry2
|
||||
obj:/usr/lib/x86_64-linux-gnu/libtinfo.so.6.3
|
||||
fun:_nc_setupterm
|
||||
fun:tgetent_sp
|
||||
fun:_rl_init_terminal_io
|
||||
fun:rl_initialize
|
||||
fun:readline
|
||||
fun:main
|
||||
}
|
||||
{
|
||||
<insert_a_suppression_name_here>
|
||||
Memcheck:Leak
|
||||
match-leak-kinds: reachable
|
||||
fun:calloc
|
||||
obj:/usr/lib/x86_64-linux-gnu/libtinfo.so.6.3
|
||||
fun:_nc_tiparm
|
||||
obj:/usr/lib/x86_64-linux-gnu/libtinfo.so.6.3
|
||||
fun:_nc_trim_sgr0
|
||||
fun:tgetent_sp
|
||||
fun:_rl_init_terminal_io
|
||||
fun:rl_initialize
|
||||
fun:readline
|
||||
fun:main
|
||||
}
|
||||
{
|
||||
<insert_a_suppression_name_here>
|
||||
Memcheck:Leak
|
||||
match-leak-kinds: reachable
|
||||
fun:malloc
|
||||
fun:xmalloc
|
||||
fun:rl_initialize
|
||||
fun:readline
|
||||
fun:main
|
||||
}
|
||||
{
|
||||
<insert_a_suppression_name_here>
|
||||
Memcheck:Leak
|
||||
match-leak-kinds: reachable
|
||||
fun:calloc
|
||||
fun:_nc_read_termtype
|
||||
obj:/usr/lib/x86_64-linux-gnu/libtinfo.so.6.3
|
||||
obj:/usr/lib/x86_64-linux-gnu/libtinfo.so.6.3
|
||||
fun:_nc_read_entry2
|
||||
obj:/usr/lib/x86_64-linux-gnu/libtinfo.so.6.3
|
||||
fun:_nc_setupterm
|
||||
fun:tgetent_sp
|
||||
fun:_rl_init_terminal_io
|
||||
fun:rl_initialize
|
||||
fun:readline
|
||||
fun:main
|
||||
}
|
||||
{
|
||||
<insert_a_suppression_name_here>
|
||||
Memcheck:Leak
|
||||
match-leak-kinds: reachable
|
||||
fun:calloc
|
||||
fun:_nc_setupterm
|
||||
fun:tgetent_sp
|
||||
fun:_rl_init_terminal_io
|
||||
fun:rl_initialize
|
||||
fun:readline
|
||||
fun:main
|
||||
}
|
||||
{
|
||||
<insert_a_suppression_name_here>
|
||||
Memcheck:Leak
|
||||
match-leak-kinds: reachable
|
||||
fun:malloc
|
||||
fun:_nc_read_termtype
|
||||
obj:/usr/lib/x86_64-linux-gnu/libtinfo.so.6.3
|
||||
obj:/usr/lib/x86_64-linux-gnu/libtinfo.so.6.3
|
||||
fun:_nc_read_entry2
|
||||
obj:/usr/lib/x86_64-linux-gnu/libtinfo.so.6.3
|
||||
fun:_nc_setupterm
|
||||
fun:tgetent_sp
|
||||
fun:_rl_init_terminal_io
|
||||
fun:rl_initialize
|
||||
fun:readline
|
||||
fun:main
|
||||
}
|
||||
{
|
||||
<insert_a_suppression_name_here>
|
||||
Memcheck:Leak
|
||||
match-leak-kinds: reachable
|
||||
fun:malloc
|
||||
fun:xrealloc
|
||||
obj:/usr/lib/x86_64-linux-gnu/libreadline.so.8.1
|
||||
obj:/usr/lib/x86_64-linux-gnu/libreadline.so.8.1
|
||||
fun:rl_redisplay
|
||||
fun:readline_internal_setup
|
||||
fun:readline
|
||||
fun:main
|
||||
}
|
||||
{
|
||||
<insert_a_suppression_name_here>
|
||||
Memcheck:Leak
|
||||
match-leak-kinds: reachable
|
||||
fun:malloc
|
||||
fun:xmalloc
|
||||
obj:/usr/lib/x86_64-linux-gnu/libreadline.so.8.1
|
||||
fun:rl_redisplay
|
||||
fun:readline_internal_setup
|
||||
fun:readline
|
||||
fun:main
|
||||
}
|
||||
{
|
||||
<insert_a_suppression_name_here>
|
||||
Memcheck:Leak
|
||||
match-leak-kinds: reachable
|
||||
fun:realloc
|
||||
fun:xrealloc
|
||||
fun:rl_add_funmap_entry
|
||||
fun:rl_initialize_funmap
|
||||
fun:rl_initialize
|
||||
fun:readline
|
||||
fun:main
|
||||
}
|
||||
{
|
||||
<insert_a_suppression_name_here>
|
||||
Memcheck:Leak
|
||||
match-leak-kinds: reachable
|
||||
fun:malloc
|
||||
fun:xmalloc
|
||||
fun:_rl_init_terminal_io
|
||||
fun:rl_initialize
|
||||
fun:readline
|
||||
fun:main
|
||||
}
|
||||
{
|
||||
<insert_a_suppression_name_here>
|
||||
Memcheck:Leak
|
||||
match-leak-kinds: reachable
|
||||
fun:malloc
|
||||
fun:xmalloc
|
||||
fun:rl_add_funmap_entry
|
||||
fun:rl_initialize_funmap
|
||||
fun:rl_initialize
|
||||
fun:readline
|
||||
fun:main
|
||||
}
|
||||
{
|
||||
<insert_a_suppression_name_here>
|
||||
Memcheck:Leak
|
||||
match-leak-kinds: reachable
|
||||
fun:malloc
|
||||
fun:xmalloc
|
||||
fun:rl_make_bare_keymap
|
||||
fun:rl_generic_bind
|
||||
fun:rl_bind_keyseq_if_unbound_in_map
|
||||
obj:/usr/lib/x86_64-linux-gnu/libreadline.so.8.1
|
||||
fun:_rl_init_terminal_io
|
||||
fun:rl_initialize
|
||||
fun:readline
|
||||
fun:main
|
||||
}
|
||||
{
|
||||
<insert_a_suppression_name_here>
|
||||
Memcheck:Leak
|
||||
match-leak-kinds: reachable
|
||||
fun:malloc
|
||||
fun:xmalloc
|
||||
fun:rl_make_bare_keymap
|
||||
fun:rl_generic_bind
|
||||
fun:rl_bind_keyseq_if_unbound_in_map
|
||||
obj:/usr/lib/x86_64-linux-gnu/libreadline.so.8.1
|
||||
fun:rl_initialize
|
||||
fun:readline
|
||||
fun:main
|
||||
}
|
||||
{
|
||||
<insert_a_suppression_name_here>
|
||||
Memcheck:Leak
|
||||
match-leak-kinds: reachable
|
||||
fun:calloc
|
||||
obj:/usr/lib/x86_64-linux-gnu/libtinfo.so.6.3
|
||||
fun:_nc_find_type_entry
|
||||
fun:tgetstr_sp
|
||||
fun:_rl_init_terminal_io
|
||||
fun:rl_initialize
|
||||
fun:readline
|
||||
fun:main
|
||||
}
|
||||
{
|
||||
<insert_a_suppression_name_here>
|
||||
Memcheck:Leak
|
||||
match-leak-kinds: reachable
|
||||
fun:malloc
|
||||
fun:xmalloc
|
||||
fun:rl_make_bare_keymap
|
||||
fun:rl_generic_bind
|
||||
fun:rl_bind_keyseq_if_unbound_in_map
|
||||
fun:rl_initialize
|
||||
fun:readline
|
||||
fun:main
|
||||
}
|
||||
{
|
||||
<insert_a_suppression_name_here>
|
||||
Memcheck:Leak
|
||||
match-leak-kinds: reachable
|
||||
fun:malloc
|
||||
fun:xmalloc
|
||||
fun:rl_make_bare_keymap
|
||||
fun:rl_generic_bind
|
||||
fun:rl_parse_and_bind
|
||||
obj:/usr/lib/x86_64-linux-gnu/libreadline.so.8.1
|
||||
fun:rl_initialize
|
||||
fun:readline
|
||||
fun:main
|
||||
}
|
||||
{
|
||||
<insert_a_suppression_name_here>
|
||||
Memcheck:Leak
|
||||
match-leak-kinds: reachable
|
||||
fun:malloc
|
||||
fun:xmalloc
|
||||
fun:sh_get_home_dir
|
||||
fun:tilde_expand_word
|
||||
fun:tilde_expand
|
||||
obj:/usr/lib/x86_64-linux-gnu/libreadline.so.8.1
|
||||
fun:rl_read_init_file
|
||||
fun:rl_initialize
|
||||
fun:readline
|
||||
fun:main
|
||||
}
|
@ -6,7 +6,7 @@
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/06/22 15:07:24 by adjoly #+# #+# */
|
||||
/* Updated: 2024/07/03 12:18:18 by adjoly ### ########.fr */
|
||||
/* Updated: 2024/07/12 15:26:48 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -38,5 +38,4 @@ void ft_cd(t_env *env, char *args)
|
||||
}
|
||||
env_edit("PWD", ft_strdup(ret_cwd()), env);
|
||||
env_edit("OLDPWD", pwd, env);
|
||||
free(args);
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/06/01 14:55:06 by mmoussou #+# #+# */
|
||||
/* Updated: 2024/07/10 01:18:17 by adjoly ### ########.fr */
|
||||
/* Updated: 2024/07/10 14:11:59 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/07/03 10:50:52 by mmoussou #+# #+# */
|
||||
/* Updated: 2024/07/09 21:21:16 by adjoly ### ########.fr */
|
||||
/* Updated: 2024/07/13 13:19:34 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -14,6 +14,8 @@
|
||||
|
||||
char *format_quotes_string(char *cmd)
|
||||
{
|
||||
if (!cmd)
|
||||
return (NULL);
|
||||
if (*cmd == DOUBLE || *cmd == SINGLE)
|
||||
ft_strlcpy(cmd, cmd + 1, ft_strlen(cmd) - 1);
|
||||
return (cmd);
|
||||
@ -23,7 +25,9 @@ int format_quotes_cmd(t_cmd *cmd, t_env *env)
|
||||
{
|
||||
uint i;
|
||||
|
||||
format_quotes_string(cmd->cmd);
|
||||
if (!cmd)
|
||||
return (-1);
|
||||
cmd->cmd = format_quotes_string(cmd->cmd);
|
||||
i = 0;
|
||||
while (cmd->argv[i])
|
||||
{
|
||||
@ -40,7 +44,8 @@ int format_quotes(t_list *list_cmd, t_env *env)
|
||||
return (0);
|
||||
while (list_cmd)
|
||||
{
|
||||
format_quotes_cmd(list_cmd->content, env);
|
||||
if (format_quotes_cmd(list_cmd->content, env))
|
||||
return (-1);
|
||||
list_cmd = list_cmd->next;
|
||||
}
|
||||
return (0);
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/20 09:19:39 by mmoussou #+# #+# */
|
||||
/* Updated: 2024/07/10 01:14:41 by adjoly ### ########.fr */
|
||||
/* Updated: 2024/07/13 14:02:22 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -73,11 +73,13 @@ static int get_input(char *delimiter, int fd)
|
||||
|
||||
void __forked(char *delimiter, int fd, t_cmd *cmd)
|
||||
{
|
||||
get_input(delimiter, fd);
|
||||
signal(SIGINT, &__heredoc_sig);
|
||||
free(cmd);
|
||||
get_input(delimiter, fd);
|
||||
ft_envclear(get_env(NULL), free);
|
||||
ft_lstclear_till_nxt(get_list2(NULL), &free_cmd);
|
||||
ft_lstclear(get_list(NULL), &free_token);
|
||||
rl_clear_history();
|
||||
close(fd);
|
||||
}
|
||||
|
||||
@ -85,6 +87,7 @@ int __heredoc(char *delimiter, t_cmd *cmd)
|
||||
{
|
||||
int fork_pid;
|
||||
int fd;
|
||||
int heredoc_ret;
|
||||
|
||||
fd = fd_manager(0);
|
||||
if (fd == -1)
|
||||
@ -105,9 +108,8 @@ int __heredoc(char *delimiter, t_cmd *cmd)
|
||||
exit(0);
|
||||
}
|
||||
else
|
||||
waitpid(fork_pid, NULL, 0);
|
||||
close(fd);
|
||||
return (fd_manager(1));
|
||||
waitpid(fork_pid, &heredoc_ret, 0);
|
||||
return (check_error(heredoc_ret, fd));
|
||||
}
|
||||
|
||||
int ft_heredoc(char *delimiter, t_cmd *cmd)
|
||||
|
@ -6,13 +6,14 @@
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/07/10 01:14:10 by adjoly #+# #+# */
|
||||
/* Updated: 2024/07/10 01:16:48 by adjoly ### ########.fr */
|
||||
/* Updated: 2024/07/13 14:03:00 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include "minishell.h"
|
||||
|
||||
int __open_fd_here(char *path, int mode)
|
||||
{
|
||||
@ -23,6 +24,7 @@ int __open_fd_here(char *path, int mode)
|
||||
else
|
||||
fd = open(path, O_WRONLY | O_TRUNC | O_CREAT, 0644);
|
||||
free(path);
|
||||
get_fd_heredoc(fd);
|
||||
return (fd);
|
||||
}
|
||||
|
||||
@ -46,3 +48,27 @@ void ft_lstclear_till_nxt(t_list **lst, void (*del)(void *))
|
||||
}
|
||||
free(*lst);
|
||||
}
|
||||
|
||||
int check_error(int heredoc_ret, int fd)
|
||||
{
|
||||
heredoc_ret = WEXITSTATUS(heredoc_ret);
|
||||
if (heredoc_ret != 0)
|
||||
{
|
||||
close(fd);
|
||||
get_exit_code(heredoc_ret);
|
||||
return (-2);
|
||||
}
|
||||
close(fd);
|
||||
return (fd_manager(1));
|
||||
}
|
||||
|
||||
void __heredoc_sig(int code)
|
||||
{
|
||||
(void)code;
|
||||
ft_envclear(get_env(NULL), free);
|
||||
ft_lstclear_till_nxt(get_list2(NULL), &free_cmd);
|
||||
ft_lstclear(get_list(NULL), &free_token);
|
||||
close(get_fd_heredoc(-1));
|
||||
rl_clear_history();
|
||||
exit(130);
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/07/09 17:24:15 by adjoly #+# #+# */
|
||||
/* Updated: 2024/07/10 00:46:24 by adjoly ### ########.fr */
|
||||
/* Updated: 2024/07/13 14:09:08 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -39,3 +39,23 @@ t_list **get_list2(t_list **list)
|
||||
ret = list;
|
||||
return (ret);
|
||||
}
|
||||
|
||||
int get_exit_code(int in)
|
||||
{
|
||||
static int exit_code;
|
||||
|
||||
if (in != -1)
|
||||
exit_code = in % 256;
|
||||
if (exit_code < 0)
|
||||
exit_code += 256;
|
||||
return (exit_code);
|
||||
}
|
||||
|
||||
int get_fd_heredoc(int in)
|
||||
{
|
||||
static int fd;
|
||||
|
||||
if (in != -1)
|
||||
fd = in;
|
||||
return (fd);
|
||||
}
|
||||
|
10
src/main.c
10
src/main.c
@ -6,7 +6,7 @@
|
||||
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/24 11:18:04 by adjoly #+# #+# */
|
||||
/* Updated: 2024/07/10 00:31:20 by adjoly ### ########.fr */
|
||||
/* Updated: 2024/07/13 13:35:37 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -74,7 +74,13 @@ int main(int ac, char **av, char **env)
|
||||
cmd_list = get_cmd_list(piped);
|
||||
free(rl);
|
||||
ft_lstclear(&piped, &free_token);
|
||||
format_quotes(cmd_list, env_l);
|
||||
if (!cmd_list)
|
||||
continue ;
|
||||
if (format_quotes(cmd_list, env_l))
|
||||
{
|
||||
ft_lstclear(get_list(NULL), &free_cmd);
|
||||
continue ;
|
||||
}
|
||||
get_list(&cmd_list);
|
||||
if (check_redir(cmd_list))
|
||||
{
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/06/05 21:14:04 by adjoly #+# #+# */
|
||||
/* Updated: 2024/07/09 20:23:16 by adjoly ### ########.fr */
|
||||
/* Updated: 2024/07/13 14:14:20 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -54,6 +54,11 @@ char *env_var_replace(char *readline, t_env *env)
|
||||
if (*tmp == '$' && is_inquote(readline, tmp - readline) != SINGLE)
|
||||
{
|
||||
tmp++;
|
||||
if ((*tmp) == '?')
|
||||
{
|
||||
tmp++;
|
||||
continue ;
|
||||
}
|
||||
dollar_size = strlen_till_notalnum(tmp);
|
||||
__cpy_dollar(tmp, dollar_size, env, &rl_dollared);
|
||||
tmp += dollar_size;
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/31 12:47:13 by adjoly #+# #+# */
|
||||
/* Updated: 2024/07/10 01:12:52 by adjoly ### ########.fr */
|
||||
/* Updated: 2024/07/13 14:08:31 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -14,20 +14,40 @@
|
||||
#include "parsing.h"
|
||||
#include "minishell.h"
|
||||
|
||||
t_list *make_lst(t_list *tmp)
|
||||
{
|
||||
t_list *cmd_list;
|
||||
|
||||
cmd_list = malloc(sizeof(t_list));
|
||||
get_list2(&cmd_list);
|
||||
cmd_list->next = NULL;
|
||||
cmd_list->content = get_redir_fd(tmp->content);
|
||||
return (cmd_list);
|
||||
}
|
||||
|
||||
t_list *get_cmd_list(t_list *list)
|
||||
{
|
||||
t_list *tmp;
|
||||
t_list *cmd_list;
|
||||
|
||||
tmp = list;
|
||||
cmd_list = malloc(sizeof(t_list));
|
||||
get_list2(&cmd_list);
|
||||
cmd_list->next = NULL;
|
||||
cmd_list->content = get_redir_fd(tmp->content);
|
||||
cmd_list = make_lst(tmp);
|
||||
if (!cmd_list->content)
|
||||
{
|
||||
free(cmd_list);
|
||||
return (NULL);
|
||||
}
|
||||
tmp = tmp->next;
|
||||
while (tmp)
|
||||
{
|
||||
ft_lstadd_back(&cmd_list, ft_lstnew(get_redir_fd(tmp->content)));
|
||||
if (!ft_lstlast(cmd_list)->content)
|
||||
{
|
||||
ft_lstclear(&cmd_list, &free_cmd);
|
||||
if (cmd_list)
|
||||
free(cmd_list);
|
||||
return (NULL);
|
||||
}
|
||||
tmp = tmp->next;
|
||||
}
|
||||
return (cmd_list);
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/30 10:48:41 by adjoly #+# #+# */
|
||||
/* Updated: 2024/07/10 01:07:50 by adjoly ### ########.fr */
|
||||
/* Updated: 2024/07/13 14:05:27 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -32,6 +32,11 @@ t_cmd *get_redir_fd(void *content)
|
||||
while (tmp)
|
||||
{
|
||||
open_redir((t_redirection *)tmp->content, cmd, sign);
|
||||
if (cmd->infile == -2)
|
||||
{
|
||||
free(cmd);
|
||||
return (NULL);
|
||||
}
|
||||
tmp = tmp->next;
|
||||
}
|
||||
if (sign[0] == INFILE)
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/06/30 15:56:53 by adjoly #+# #+# */
|
||||
/* Updated: 2024/07/10 01:07:09 by adjoly ### ########.fr */
|
||||
/* Updated: 2024/07/13 13:47:38 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -29,10 +29,14 @@ void open_redir(t_redirection *redir, t_cmd *cmd, t_redir_sign sign[2])
|
||||
{
|
||||
if (redir->sign == OUTFILE || redir->sign == OUT_APPEND)
|
||||
sign[0] = __close_unused_fd(cmd, redir->sign);
|
||||
if (redir->sign == INFILE || redir->sign == HEREDOC)
|
||||
else if (redir->sign == INFILE || redir->sign == HEREDOC)
|
||||
sign[1] = __close_unused_fd(cmd, redir->sign);
|
||||
if (redir->sign == HEREDOC)
|
||||
{
|
||||
cmd->infile = ft_heredoc(redir->file_name, cmd);
|
||||
if (cmd->infile == -2)
|
||||
return ;
|
||||
}
|
||||
else if (redir->sign == INFILE)
|
||||
cmd->infile = open(redir->file_name, O_RDONLY);
|
||||
else if (redir->sign == OUTFILE)
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/20 21:05:04 by adjoly #+# #+# */
|
||||
/* Updated: 2024/07/09 23:43:39 by adjoly ### ########.fr */
|
||||
/* Updated: 2024/07/11 13:49:40 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -53,7 +53,9 @@ t_token *__to_token(char *cmd)
|
||||
tmp += __get_sizeof_redir(tmp, tmp_redir);
|
||||
}
|
||||
else
|
||||
{
|
||||
token->argv = ft_strjoin_free(token->argv, ft_substr(tmp, 0, 1));
|
||||
}
|
||||
tmp++;
|
||||
}
|
||||
return (token);
|
||||
|
Reference in New Issue
Block a user