Polished echo, and the builtins should work now (not tested in pipes)
This commit is contained in:
parent
85910da2fd
commit
45a55df528
9 changed files with 118 additions and 57 deletions
|
|
@ -6,7 +6,7 @@
|
|||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/08/10 18:43:18 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/08/10 19:47:34 by maiboyer ### ########.fr */
|
||||
/* Updated: 2024/08/11 11:30:09 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
#include "me/string/string.h"
|
||||
#include "me/types.h"
|
||||
|
||||
t_error builtin_echo__(t_state *state, t_spawn_info info)
|
||||
t_error builtin_echo__(t_state *state, t_builtin_spawn_info info, t_i32 *exit_code)
|
||||
{
|
||||
t_usize i;
|
||||
bool print_line;
|
||||
|
|
@ -25,21 +25,22 @@ t_error builtin_echo__(t_state *state, t_spawn_info info)
|
|||
print_line = true;
|
||||
i = 1;
|
||||
s = string_new(1024);
|
||||
if (i < info.arguments.len && str_compare(info.arguments.buffer[i], "-n"))
|
||||
if (i < info.args.len && str_compare(info.args.buffer[i], "-n"))
|
||||
{
|
||||
print_line = false;
|
||||
i++;
|
||||
}
|
||||
while (i < info.arguments.len - 1)
|
||||
while (i < info.args.len - 1)
|
||||
{
|
||||
string_push(&s, info.arguments.buffer[i++]);
|
||||
string_push(&s, info.args.buffer[i++]);
|
||||
string_push_char(&s, ' ');
|
||||
}
|
||||
if (i < info.arguments.len)
|
||||
string_push(&s, info.arguments.buffer[i]);
|
||||
if (i < info.args.len)
|
||||
string_push(&s, info.args.buffer[i]);
|
||||
if (print_line)
|
||||
string_push_char(&s, '\n');
|
||||
// TODO: change the null to the actual redirection thingy, this needs to be done in the handle_builtin function beforehand
|
||||
me_printf_fd(NULL, "%s", s.buf);
|
||||
return (NO_ERROR);
|
||||
me_printf_fd(info.stdout, "%s", s.buf);
|
||||
string_free(s);
|
||||
return (*exit_code = 0, NO_ERROR);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue