Closed haoadoreorange closed 2 years ago
how bass import bash functions to fish when sourcing a file
Bass does not really import bash functions. When you source a bash script in bash, two things can happen:
When you source a bash script (e.g. nvm.sh
) through bass, bass creates a temporary wrapper bash script that roughly does the following when sourced:
nvm.sh
)Bass then launch a bash subprocess and source the above wrapper script.
Now let's look at the two things that original script (nvm.sh
) wants to do:
The reason you have to source nvm every time you use it is because you use nvm through its subcommands (like nvm use
). Bass does not import nvm functionality to fish, so Bass still has to invoke the nvm with subcommands in a bash shell. Because Bass has to use a new bash shell subprocess to run the subcommand, it has to ask each subprocess to source nvm.sh to get the nvm functionality before running the subcommand.
Let me know if this makes sense.
Yes totally ! Thanks so much for the explanation ! I close the issue here (:+1:
First I'm sorry if this isn't the right place to ask.
I'm trying to learn how to interact between bash and fish, and bass is an excellent example. I can't understand how bass import bash functions to fish when sourcing a file, I thought it should read and redefine the functions in fish but it's not the case, for example for nvm use case.
And then, providing that bass import the function to fish, why do we need to source everytime we run nvm ? Isn't sourcing on first session enough ?