I want to write my functions each in separate files, for easier version control, and source the whole lot of them in my
Is there a more robust way than e.g.
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
It's simply a matter of surrounding it all with appropriate error checks:
FNDIR=~/.bash_functions if [ -d $FNDIR ] then for f in $FNDIR/*.sh do test -x $f && source $f done fi
I'm purposely not quoting values here because I'm making an assumption that you're not going to have a home directory or script name with spaces in it. That seems to go beyond robustness and into protection against malice. Since these are scripts you are writing for yourself, I don't think we need to go that far. :)