We have an exec that work (only once tho)
This commit is contained in:
parent
8ee24b1bcf
commit
887601bf2b
8 changed files with 25 additions and 34 deletions
4
Makefile
4
Makefile
|
|
@ -6,7 +6,7 @@
|
|||
# By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ #
|
||||
# +#+#+#+#+#+ +#+ #
|
||||
# Created: 2023/11/12 11:05:05 by rparodi #+# #+# #
|
||||
# Updated: 2024/08/02 22:42:24 by maiboyer ### ########.fr #
|
||||
# Updated: 2024/08/03 16:22:06 by maiboyer ### ########.fr #
|
||||
# #
|
||||
# **************************************************************************** #
|
||||
|
||||
|
|
@ -41,7 +41,7 @@ endif
|
|||
endif
|
||||
|
||||
# TODO: ADD THIS WHEN FINISHING THIS:
|
||||
# CFLAGS_ADDITIONAL += -DNVALGRIND
|
||||
CFLAGS_ADDITIONAL += -DNVALGRIND
|
||||
|
||||
# TODO: REMOVE THIS WHEN FINISHING THIS:
|
||||
CFLAGS_ADDITIONAL += -DPRINT_BACKTRACE
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/07/11 17:22:29 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/08/03 16:13:05 by maiboyer ### ########.fr */
|
||||
/* Updated: 2024/08/03 16:20:04 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -516,6 +516,7 @@ t_error run_program(t_ast_program *self, t_state *state, t_program_result *out)
|
|||
;
|
||||
else
|
||||
;
|
||||
i++;
|
||||
}
|
||||
|
||||
return (ERROR);
|
||||
|
|
|
|||
|
|
@ -1,24 +1,21 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* vec_str.c :+: :+: :+: */
|
||||
/* str_functions2.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/12/30 17:59:28 by maiboyer #+# #+# */
|
||||
/* Updated: 2023/12/30 17:59:28 by maiboyer ### ########.fr */
|
||||
/* Updated: 2024/08/03 16:23:05 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "me/mem/mem.h"
|
||||
#include "me/mem/mem.h"
|
||||
#include "me/mem/mem.h"
|
||||
#include "me/types.h"
|
||||
#include "me/vec/vec_str.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
t_error vec_str_find(t_vec_str *vec,
|
||||
bool (*fn)(const t_str *), t_usize *index)
|
||||
t_error vec_str_find(t_vec_str *vec, bool (*fn)(const t_str *), t_usize *index)
|
||||
{
|
||||
t_usize idx;
|
||||
|
||||
|
|
@ -37,9 +34,7 @@ t_error vec_str_find(t_vec_str *vec,
|
|||
return (ERROR);
|
||||
}
|
||||
|
||||
t_error vec_str_find_starting(t_vec_str *vec,
|
||||
bool (*fn)(const t_str *),
|
||||
t_usize starting_index, t_usize *index)
|
||||
t_error vec_str_find_starting(t_vec_str *vec, bool (*fn)(const t_str *), t_usize starting_index, t_usize *index)
|
||||
{
|
||||
t_usize idx;
|
||||
|
||||
|
|
@ -58,8 +53,7 @@ t_error vec_str_find_starting(t_vec_str *vec,
|
|||
return (ERROR);
|
||||
}
|
||||
|
||||
t_error vec_str_all(t_vec_str *vec,
|
||||
bool (*fn)(const t_str *), bool *result)
|
||||
t_error vec_str_all(t_vec_str *vec, bool (*fn)(const t_str *), bool *result)
|
||||
{
|
||||
t_usize idx;
|
||||
|
||||
|
|
@ -76,8 +70,7 @@ t_error vec_str_all(t_vec_str *vec,
|
|||
return (ERROR);
|
||||
}
|
||||
|
||||
t_error vec_str_any(t_vec_str *vec,
|
||||
bool (*fn)(const t_str *), bool *result)
|
||||
t_error vec_str_any(t_vec_str *vec, bool (*fn)(const t_str *), bool *result)
|
||||
{
|
||||
t_usize idx;
|
||||
|
||||
|
|
@ -94,10 +87,7 @@ t_error vec_str_any(t_vec_str *vec,
|
|||
return (ERROR);
|
||||
}
|
||||
|
||||
void vec_str_iter(t_vec_str *vec,
|
||||
void (*fn)(t_usize index, t_str *value,
|
||||
void *state),
|
||||
void *state)
|
||||
void vec_str_iter(t_vec_str *vec, void (*fn)(t_usize index, t_str *value, void *state), void *state)
|
||||
{
|
||||
t_usize idx;
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/04 18:32:50 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/08/02 22:37:23 by maiboyer ### ########.fr */
|
||||
/* Updated: 2024/08/03 16:31:34 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -55,11 +55,15 @@ t_error _build_envp_iterator(t_usize idx, const t_str *key, t_str *val,
|
|||
{
|
||||
struct s_build_envp_state *s;
|
||||
t_str push;
|
||||
t_str *nval;
|
||||
|
||||
(void)(idx);
|
||||
s = ctx;
|
||||
nval = hmap_env_get(s->tmp_vars, (t_str *)key);
|
||||
if (nval == NULL)
|
||||
nval = val;
|
||||
if (string_push(&s->buf, *key) || string_push(&s->buf, "=") || \
|
||||
string_push(&s->buf, *val))
|
||||
string_push(&s->buf, *nval))
|
||||
return (vec_str_free(s->out), ERROR);
|
||||
push = str_clone(s->buf.buf);
|
||||
if (vec_str_push(&s->out, push))
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/03/28 14:40:38 by rparodi #+# #+# */
|
||||
/* Updated: 2024/08/03 16:16:12 by maiboyer ### ########.fr */
|
||||
/* Updated: 2024/08/03 16:18:41 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -157,6 +157,7 @@ void ft_take_args(t_state *state)
|
|||
line_history_add(state->str_input);
|
||||
state->current_node = parse_str(state);
|
||||
exec_shcat(state);
|
||||
ft_exit(state, 42);
|
||||
mem_free(state->str_input);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/02 13:22:14 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/08/02 12:17:50 by rparodi ### ########.fr */
|
||||
/* Updated: 2024/08/03 16:34:19 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/01/03 16:22:41 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/08/02 19:11:00 by maiboyer ### ########.fr */
|
||||
/* Updated: 2024/08/03 16:34:46 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -27,8 +27,6 @@ t_error handle_redirections(t_spawn_info *info, t_process *process);
|
|||
|
||||
t_error spawn_process_exec(t_spawn_info info, t_process *process)
|
||||
{
|
||||
bool res;
|
||||
|
||||
if (info.forked_free)
|
||||
info.forked_free(info.forked_free_args);
|
||||
dup2(info.stdin.fd.fd->fd, 0);
|
||||
|
|
@ -40,10 +38,7 @@ t_error spawn_process_exec(t_spawn_info info, t_process *process)
|
|||
close_fd(info.stdin.fd.fd);
|
||||
close_fd(info.stdout.fd.fd);
|
||||
close_fd(info.stderr.fd.fd);
|
||||
if (!vec_str_any(&info.arguments, _find_null, &res) && res)
|
||||
vec_str_push(&info.arguments, NULL);
|
||||
res = false;
|
||||
if (!vec_str_any(&info.environement, _find_null, &res) && res)
|
||||
vec_str_push(&info.environement, NULL);
|
||||
execve(info.binary_path, info.arguments.buffer, info.environement.buffer);
|
||||
return (NO_ERROR);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/08/17 15:56:59 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/07/30 16:11:22 by rparodi ### ########.fr */
|
||||
/* Updated: 2024/08/03 16:33:53 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -31,7 +31,7 @@ t_error str_split(t_const_str str, t_const_str chr, t_vec_str *out)
|
|||
while (str[idx] != '\0' && str_find_chr(chr, str[idx]) != NULL)
|
||||
idx++;
|
||||
while (str[idx] != '\0' && str_find_chr(chr, str[idx]) == NULL)
|
||||
string_push_char(&buf, str[idx]);
|
||||
string_push_char(&buf, str[idx++]);
|
||||
if (buf.len != 0)
|
||||
{
|
||||
vec_str_push(&ret, buf.buf);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue