Both Python and RubyAt least one shell, fish, doesn't exhibit this behaviour for me(but then fish is unusual in other ways):
% printffor "%s\n"sh 'importin time'zsh 'time.sleep(3)'mksh >fish foo.py;dash python3bash foo.pytcsh; &do echo 'print("foo")''sleep >>5' > foo.py; fg $sh; $sh foo.$sh & sleep 1; echo 'echo $0' >> foo.$sh; fg; done
[1][2] 41037381
[1][2] +- 41037381 running python3$sh foo.py$sh
foo
.zsh
% echo[2] 'sleep(3)'7385
[2] > foo.rb;- ruby7385 foo.rbrunning & echo 'puts("foo")' >>$sh foo.rb & fg $sh
[1] 4121foo.mksh
[2] 41227387
[2] - 41227387 running echo 'puts("foo")' >>$sh foo.rb$sh
%[2] foo
7390
[1] + 4121[2] done - 7390 running ruby$sh foo.rb
$sh
% python3 -Vfoo.dash
Python[2] 3.6.57393
%[2] ruby --version 7393 running $sh foo.$sh
foo.bash
[2] 7415
[2] - 7415 running ruby$sh 2foo.5$sh
foo.1p57 (2018-03-29 revision 63029) [x86_64-linux]tcsh
I believe any interpreter capable(A previous version of readingthis answer had mistaken observations of Python and executing instructions as they come from a pipeline should behave the same wayRuby.)