Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The trick is to enter bash from fish, run your command, and then call fish again.

    (fish)$ bash
    (fish>bash)$ source ./random.sh
    (fish>bash)$ fish
    (fish>bash>fish)$


I think you should hit ctrl+d when you are done in bash to avoid the nested fish>bash>fish.


The idea is to return to a fish shell, but with all the env-vars that bash might have loaded as a result of executing the script.


`exec <shell>` would avoid nested shells and inherit the environment. Which might be preferable if you find your terminal emulator complaining about processes still running on close.


Would it be better to ‘exec’ the shells to avoid the nesting?


Or just simply:

    (fish)$ bash -c ./random.sh


That doesn't give you the env vars that the script might have set.


You can use fenv or bass for that. They run a snippet or script of bash in bash, then import all the environment changes for you

https://github.com/oh-my-fish/plugin-foreign-env

https://github.com/edc/bass


could you explain this? How could the script set env vars before you run it??


No need to use -c there:

    (fish)$ bash random.sh




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: