I decided to try fish shell, and I'm having trouble with some aliases. So I guess the painless way of doing the things would be executing the bash commands inside fish shell functions. Something like that :

function fish_function
start bash
    ... bash commands ... 
stop bash

Is that possible?

e.g: the command

pacman -Qtdq && sudo pacman -Rns $(pacman -Qtdq) 

doesn't work in fish shell and I have no idea how to convert this

  • I read that fish uses () for command subsitutions. Just try to remove the $.
    – kos
    Mar 4, 2016 at 19:13
  • worked ! (after substituting '&&' for ';and')
    – tjbrn
    Mar 4, 2016 at 19:31

1 Answer 1


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

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 '

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.