Apparently fish uses ; and
for &&
and ()
for command substitutions.
So just changing the command to
pacman -Qtdq; and sudo pacman -Rns (pacman -Qtdq)
should work.
Answering the actual question, normally you can get a statement to be executed in Bash simply by redirecting the statement to a bash
command's STDIN by any mean (notice that I'm on Zsh, which supports here strings, and that the statement prints the content of a Bash-specific variable):
% <<<'echo $BASH' bash
/bin/bash
However as a general rule I'd suggest to use bash
's -c
option. For example here strings and pipes don't play too well with multiple commands, here documents will be expanded by the current shell, etc (nevertheless those need to be supported by the current shell).
Overall bash -c
seems to be always a safe bet:
bash -c 'pacman -Qtdq && sudo pacman -Rns $(pacman -Qtdq)'
Which for multiple commands becomes something like this:
bash -c '
command1
command2
command3
'
()
for command subsitutions. Just try to remove the$
. – kos Mar 04 '16 at 19:13