Consider the following shell script
echo foo; read; echo bar
bash my_script outputs 'foo', waits for the return key and outputs 'bar'.
While this works fine running it that way, it doesn't work anymore if piped to /bin/bash:
$ echo 'echo foo;read;echo bar'|bash
directly outputs 'foo' and 'bar' without waiting for a key press.
Why doesn't read work anymore when using it this way?
Is there any way to rewrite the script in a way it works as file script file as well as a script string piped to /bin/bash?