Fixed waiting on previous command for pipeline to spawn next
This commit is contained in:
parent
45bacdd3c0
commit
aac10822d3
13 changed files with 679 additions and 52 deletions
|
|
@ -6,7 +6,7 @@
|
|||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/08/10 18:43:18 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/08/12 17:25:25 by maiboyer ### ########.fr */
|
||||
/* Updated: 2024/08/13 15:13:11 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -22,6 +22,7 @@ t_error builtin_cd____(t_state *state, t_builtin_spawn_info info, t_i32 *exit_co
|
|||
{
|
||||
const t_str key = "HOME";
|
||||
t_str *home;
|
||||
t_str path;
|
||||
|
||||
if (info.args.len <= 1)
|
||||
{
|
||||
|
|
@ -30,10 +31,11 @@ t_error builtin_cd____(t_state *state, t_builtin_spawn_info info, t_i32 *exit_co
|
|||
home = hmap_env_get(state->env, (t_str *)&key);
|
||||
if (home == NULL || *home == NULL)
|
||||
return (*exit_code = 0, NO_ERROR);
|
||||
if (chdir(*home) == -1)
|
||||
return (*exit_code = 2, me_printf_fd(info.stderr, "cd: Unable to change directory\n"), NO_ERROR);
|
||||
path = *home;
|
||||
}
|
||||
else if (chdir(info.args.buffer[1]) == -1)
|
||||
else
|
||||
path = info.args.buffer[1];
|
||||
if (chdir(path) == -1)
|
||||
return (*exit_code = 2, me_printf_fd(info.stderr, "cd: Unable to change directory\n"), NO_ERROR);
|
||||
return (*exit_code = 0, NO_ERROR);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,12 +6,12 @@
|
|||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/08/07 13:58:37 by rparodi #+# #+# */
|
||||
/* Updated: 2024/08/12 18:14:08 by rparodi ### ########.fr */
|
||||
/* Updated: 2024/08/13 15:14:47 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "exec/builtins.h"
|
||||
#include "me/mem/mem.h"
|
||||
#include "me/printf/printf.h"
|
||||
#include "me/string/string.h"
|
||||
#include "me/types.h"
|
||||
#include <errno.h>
|
||||
|
|
@ -26,9 +26,9 @@ t_error builtin_pwd___(t_state *state, t_builtin_spawn_info info, t_i32 *exit_co
|
|||
if (errno == ERANGE)
|
||||
string_reserve(&s, s.capacity * 3);
|
||||
else
|
||||
return (string_free(s), ERROR);
|
||||
return (*exit_code = 1, string_free(s), me_printf_fd(info.stderr, "cd: Unable to get current directory\n"), NO_ERROR);
|
||||
}
|
||||
printf("%s\n", s.buf);
|
||||
me_printf_fd(info.stdout, "%s\n", s.buf);
|
||||
string_free(s);
|
||||
return (*exit_code = 0, NO_ERROR);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue