In order to pass my script's stdin to stdin of a command in an alacritty instance it spawns, I'm trying to redirect it to a file in the background (so that the command can start reading it):
t="$(mktemp --directory)"
in="$t/in"
#mkfifo "$in"
out="$t/out"
#mkfifo "$out"
cat - 3>"$in" >&3 &
alacritty -e /bin/sh -c "cat '$in' | {...} > '$out'" >&2
cat "$out"
As you can see, I tried making it a named pipe, and also using fd3 thinking the problem might be some sort of special casing that backgrounded processes don't get a 'stdin' file descriptor.
In case it's not clear, the reason for trying is that the input may be large enough that I want to start the ...
process without waiting for EOF.
I'm probably going about this all wrong - is there a way to 'reassign' 'my' file descriptors to the shell launched by alacritty? That was my first thought, but I couldn't find anything on passing file descriptors from a shell, just C (etc.) pointers.
something | this-script | something-else
, wheresomething
varies, essentially it's to be a poor man'sdmenu
for some cases. Shell - currently just targeting POSIX/bin/sh
, but requiringbash
is fine if it somehow really makes life easier.