Ok, I think I have a clue what is going on.
The behaviour you are observing in zsh and bash when executing echo $(mc)
is caused by mc
.
When you run mc
normally, it doesn't react when Ctrl+c is pressed, since it ignores SIGINT
. The way to end mc
is by pressing F10 and Enter.
When you run echo $(mc)
the input goes to the mc
process, so it is no wonder that when you press Ctrl+c nothing will happen, because mc
ignores SIGINT
.
But when you run echo $(mc)
and press F10 and Enter it will react.
(When I then press F10 and Enter again it actually quits; it should quit at the first try but I have no idea why it does not.)
From this fact I deduce that Midnight Commander is running normally, but the output from it is put into the shell buffer, so it can later be used by echo
.
Something we should consider normal.
Also you think that bash and zsh are hanging, but I would say that they are not hanging but waiting for the echo
command to return.
But echo
can only return when mc
returns, which it only does when F10 and Enter are pressed.
With this we can also explain what happens when you press Ctrl+z.
By pressing the combination mc
goes to sleep like it would if you had run mc
normally and echo
is still waiting for the sleeping mc
.
So everything is normal behavior.
Except for what fish does.
fish seems to start commands run with echo ($command)
in the background.
It kind of makes sense, since such a command normally does not need any input.
For the why and how I have no answer.
But you can see that it runs in the background when you enter
echo (mc)
jobs
When bash is run as a non-interactive shell it will not source the .bashrc
file and if you use a graphical display manager then the login shell used to run the GUI launcher commands might not have sourced the .profile
file. Thus, commands run using the GUI launcher might not have the desired environment variables set when run.
A workaround I found was to tell the terminal emulator to run bash in interactive mode (with the -i flag) and then immediately run fish inside of it:
xfce4-terminal -e 'bash -i -c fish'
Best Answer
Instead of
&&
, which doesn't exist infish
, use;
and the commandand
:According to the
fish
tutorial: