I know how to (more or less) do this in C:
#include <stdio.h>
#include <string.h>
int
main(int argc, char** argv)
{
char buf[BUFSIZ];
fgets(buf, sizeof buf, stdin); // reads STDIN into buffer `buf` line by line
if (buf[strlen(buf) - 1] == '\n')
{
printf("%s", buf);
}
return 0;
}
The desired end result being to read STDIN from a pipe, if present. (I know the above code doesn't do that, but I couldn't figure out how to only do the above when reading from a pipe/heredoc).
How would I do something similar in Chicken Scheme?
Like I said before, the end goal is to be able to do this:
echo 'a' | ./read-stdin
# a
./read-stdin << EOF
a
EOF
# a
./read-stdin <<< "a"
# a
./read-stdin <(echo "a")
# a
./read-stdin < <(echo "a")
# a