echo
A very basic echo (doesn't support coreutils echo parameters except -n
):
#include <stdio.h>
#include <string.h>
#define true 1
#define false 0
int main(int argc, char *argv[])
{
int display_return = true;
for(int i = 1; i < argc; i++)
{
// Parse arguments:
// -n = don't output trailing newline
if(strcmp("-n", argv[i]) == 0) {
display_return = false;
continue;
}
// Output arg if not a parameter
printf("%s", argv[i]);
if(i < (argc - 1))
printf(" ");
}
// Show trailing newline
if(display_return == true)
printf("\n");
}
To run:
$ wasmer run -- echo.wasm -n this is a test # notice the "--"