mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
Added echo(1).
This commit is contained in:
parent
b6a0fd0374
commit
867627c085
2 changed files with 25 additions and 0 deletions
|
@ -7,6 +7,7 @@ LOCALBINARIES:=\
|
|||
init \
|
||||
cat \
|
||||
cp \
|
||||
echo \
|
||||
rm \
|
||||
sh \
|
||||
mxsh \
|
||||
|
|
24
utils/echo.cpp
Normal file
24
utils/echo.cpp
Normal file
|
@ -0,0 +1,24 @@
|
|||
#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;
|
||||
}
|
Loading…
Add table
Reference in a new issue