1
0
Fork 0
mirror of https://gitlab.com/sortix/sortix.git synced 2023-02-13 20:55:38 -05:00
sortix--sortix/utils/echo.cpp
Jonas 'Sortie' Termansen 867627c085 Added echo(1).
2011-11-26 00:54:17 +01:00

24 lines
405 B
C++

#include <stdio.h>
#include <string.h>
int main(int argc, char* argv[])
{
int startfrom = 1;
bool trailingnewline = true;
if ( 1 < argc && strcmp(argv[1], "-n") == 0 )
{
trailingnewline = false;
startfrom = 2;
}
const char* prefix = "";
for ( int i = startfrom; i < argc; i++ )
{
printf("%s%s", prefix, argv[i]);
prefix = " ";
}
if ( trailingnewline ) { printf("\n"); }
return 0;
}