NOTE: This question has arisen due to asynchronous processing of 'Process Substitution'. The script responses were deceptive, causing many lost hours. A previously related post is here: cat in process substitution hangs: what is it waiting for?
Bash 4.4.19(1)-release
Using this code because I cannot use pipes.
func() {
in=$(cat)
echo "'this is it: $in'"
}
echo "a string" > >(func)
This Process Substitution unfortunately is printing the prompt along with my string.
user@srv:~$ ./test.sh
user@srv:~$ 'this is it: a string'
This is undesirable for my usage! to say the least!!!
What is desirable is normal behavior like so:
user@srv:~$ ./test.sh
'this is it: a string'
Can I force Process Substitution not to print a shell prompt?
NOTE: I cannot use pipes... it creates other problems for me. These are the problems it creates: Can I process command output just before sending it to a file (one liner)?
PS1
though. – jesse_b Jun 12 '19 at 21:51cat
must have been used. How was the variable's value actually assigned? It's actually quite difficult to accidentally capture the shell's prompt. – Kusalananda Jun 12 '19 at 23:19$in
, the output from your code gets intermingled with the shell displaying the prompt. It's an artefact of asynchronous output of the shell and the process substitution. – Kusalananda Jun 12 '19 at 23:28echo hello | func
. That's even portable. – Kusalananda Jun 12 '19 at 23:30