Say I want to run `sed` on a file. Is there anywa...
# plugins
f
Say I want to run
sed
on a file. Is there anyway to put the contents of the file directly on the stdin of the Process object? Or do I need to actually use a shell so I can use
<
to redirect it from a file I put in the
input_digest
?
h
Yep
I just merged a change that did something similar
f
If I were to submit a PR to expose stdin would you be open to it? It'll be a good learning opportunity for me.
h
How would this work? You'd pass
bytes
into
Process
on the Python side, and the engine would feed those bytes into the process when it executes?
f
Yeah, same thing that happens with stdout/stderr but in reverse.
h
I think that could make sense, if you want to take a swipe at it
will require some Rust work
f
Yeah, I found at least some of it. I'll have to start playing with it to find the rest.
Give me a few weeks to find the time to work on it.
👍 1
h
Why not
cat
though, as in the example I sent?
Seems easier perhaps?
Oh, and I just noticed that the specific process you want to run is
sed
, which can take an input file as an argument, so why is any of this an issue?
f
Cat isn't really needed as I can just use < on the command line. But it's more of a UI thing. If I give users arbitrary shell command line they're going to be able to run anything, use aliases out of their .cshrc files, etc. If I just give them a library of specific commands with stdin and out wired up to files, it's very clear to them that they're in an isolated environment.
And if I can avoid the shell entirely, I don't have to worry about the Joker who tries a filename with
; rm -rf /
embedded in it. Yes, our verification engineers WILL try that with four of them clustered around the screen to watch
h
But why not just
sed <some arguments> path/to/file
?
Or is
sed
just an example?
f
Well, both. In this particular case it literally is sed, but it's just one case of many, others that do require stdin
h
Gotcha
makes sense then
Can you open an issue for this, so we can briefly discuss design?
I assume the stdin data is "not huge" in your use case?
Well, we need to account for that either way
f