I have one script with common functions that is included in other my scripts with:
. ~/bin/fns
Since my ~/bin
path is on the PATH, is there a way to prevent users to execute fns
from command line (by returning from the script with a message), but to allow other scripts to include this file?
(Bash >= 4)
Just remove the executable bit with chmod -x . ~/bin/fns
. It will still work when sourced, but you can't call it (accidentally) by its name anymore.