I have this piece of code using Process Substitution.
When I run it, it works fine, but it does not exit - just hangs there waiting for input.
Why and how to overcome?
prepro() {
in=$(< <(cat) ) # capture input
echo -e "$in"
}
echo -e "some words" > >(prepro)
echo "FINISHED"
Instead if I do this, it exits immediately.
echo -e "$in" >>"test.log"
What am I missing here?
CLARIFICATION: BASH 4.4.19(1)-release
On my pc, I see a difference between running echo -e "$in"
and running echo -e "$in" >>"test.log"
.
The former does not give me a prompt (but I can run commands normally). I get:
user@server:~$ ./test.sh
FINISHED
user@server:~$ some words
█
I have to press ENTER to get my prompt back.
The latter gives me the prompt normally.
user@server:~$ ./test.sh
FINISHED
user@server:~$ █
I am curious if I am doing something wrong here.
some words
. I'm sure this has been asked before, hang on. – Gilles 'SO- stop being evil' Jun 12 '19 at 21:08