In bash, sometimes I would like to reuse a function in several scripts. Is it bad to repeat the definition of the function in all the scripts? If so, what is some good practice?
Is the following way a good idea?
- wrap the definition of a function
myfunctionin its own scriptdefine_myfunction.sh, - in any script where the function is called,
source define_myfunction.shthe script, and then call the functionmyfunction arg1 arg2 ....
Thanks.