I thought that
bytesavailable would solve this issue (based on this), but I will demonstrate that it doesn’t work.
Say I have the following script:
Now I check how many bytes there are in a dummy file:
$ wc -c foo.txt 21 foo.txt
So piping this file into the Julia script show display 21, I thought—but it displays zero:
$ cat foo.txt | julia test.jl 0
Does anyone know how to detect if anything has been passed to the script via
stdin? The goal is to have something like this:
bytesavailable(stdin) > 0 ? println(read(stdin, String)) : println("No stdin given")
Thanks in advance!