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

前端 未结 2 1030
一生所求
一生所求 2021-01-13 13:36

I have a Projection function in my bash_profile. Now I am trying to call this function from a bash script however I get a not found error. How do I make the projection funct

2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-13 13:54

    The sane but not necessarily elegant approach is to put the function in a separate file, and source it from your profile and from your script.

    You need to export the function if you want to make it available to all your scripts, but -- as with global variables -- this is not very maintainable in the long run.

提交回复
热议问题