How to use function defined in bash profile in bash script?

I have a Projection function in my bash_profile. Now I am trying to call this function from a bash script, however I am getting an error not found. How to make projection function visible for bash script?

+4
source share
2 answers

You must export a function

export -f foo 

ref

+1
source

A reasonable, but not necessarily elegant, approach is to put the function in a separate file and fix it from your profile and from your script.

You need to export this function if you want to make it available for all your scripts, but - as for global variables - it is not very convenient for maintenance in the end.

0
source

All Articles