wanpeebaw
2020-4-4 18:47:02

@wanpeebaw has joined the channel


greg
2020-4-5 04:18:32

It sounds like you want something like input-port-append https://docs.racket-lang.org/reference/port-lib.html#(def._((lib._racket%2Fport..rkt)._input-port-append)) — but I don’t see how this could work without help from the OS/shell, providing you both ports, or doing the concatenation to one, for you? Is there some Bash or whatever construct that does this, e.g. cat "foo" <<some-magic-thing-that-means-stdin>> \| racket myscript.rkt?


greg
2020-4-5 04:25:03

My shell fu is weak. I guess for cat, - is the magic thing meaning stdin.


greg
2020-4-5 04:25:49

But you can’t cat "hello", just a file or -. So some other trick is needed.


greg
2020-4-5 04:36:41

I think something like cat <(echo "hello") - \| racket myscript.rkt would work, although that uses process substitution.


ryanc
2020-4-5 04:45:52

As far as I know there’s no good way to do this. Note that with greg’s solution, Racket’s stdin will not be a tty, so useful things like readline won’t work.


ryanc
2020-4-5 04:47:07

Is there a reason not to pass the extra input as a command line argument?


ryanc
2020-4-5 04:54:40

Process substitution, which Greg mentioned, seems like a nice way of handling pipelined inputs (even multiple inputs) without interfering with the controlling terminal. (Neat!)