This is my script, test.sh
if ssh myhost true; then
echo 1
fi
echo 2
p.s. I have setup ssh key for myhost, so it won't ask password.
If I run it via bash, it will output two lines
$ bash test.sh
1
2
However, if I redirect the script to bash's stdin, it only output one line
$ bash < test.sh
1
Why do bash behave differently? Is this a bug of bash or a magic feature?
I have tried bash 4.3 and 4.4.
p.s. If I replace ssh myhost true
with true
, the script will always output two lines.