First of all, I'm on OSX10. My default shell is BASH, which I have set up (through .profile and .bashrc) to automatically run the FISH shell when I open my terminal emulator. This allows me to set up variables etc. in BASH before I load up FISH.

Sometimes, however, I want to run scripts which are written for BASH, from my FISH shell. This is necessary because FISH isn't syntactically compatible with BASH. When typing 'bash' in my FISH, the BASH I open automatically opens another FISH on top of itself, because of my .profile/.bashrc. That makes it all fishy (pun intended), because I then have to exit the top FISH to get into the BASH on top of the second FISH.

My question is: I know BASH can be loaded up as a login shell (executing .profile), and a non-login shell (executing .bashrc). Would it be possible to add a third 'context', which I can set up to load when BASH is run from inside FISH? That would solve the double-FISH problem because I'd be able not to load either .bashrc or .profile.

I hope you understand my question -- thanks in advance for answers!


You could set a variable in the script which starts fish to note that you're "in fish":

export IN_FISH=yes

Then, before that, you check whether it's already set:

if [ "${IN_FISH}" != "yes" ]; then
    export IN_FISH=yes
    fish  # replace with the command you use to start fish

Thus, in your first bash, IN_FISH isn't set, so it gets set and fish is started. When you start bash from FISH, IN_FISH is already set, so bash doesn't start fish again...


Also, I was thinking, you could edit the script to explicitly use BASH by inserting a:


in the script as the first line

e.g. #!/bin/bash

or do an explicit


call e.g. /bin/bash/scripttorun

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.