Luna/shell/builtin/echo.cpp
2024-04-20 17:17:31 +02:00

21 lines
416 B
C++

#include "sh.h"
#include <os/ArgumentParser.h>
#include <stdio.h>
void print_sequenced(const char* string, bool& state)
{
if (!state) { putchar(' '); }
state = false;
fputs(string, stdout);
}
shell_builtin_t builtin_echo = [](int argc, char** argv) -> Result<void> {
bool state = true;
for (int i = 1; i < argc; i++) { print_sequenced(argv[i], state); }
putchar('\n');
return {};
};