I make an array of files as follows, and then "source" those files. I am also trying to make a script as close to POSIX possible so I don't have issues running it in different shells.
set -- path alias function
for file in "${@}"; do
[ -r "${SELF_PATH_DIR}.${file}" ] && [ -f "${SELF_PATH_DIR}.${file}" ] && . "${SELF_PATH_DIR}.${file}";
done
It works, but I don't like the fact that I have to specify ${SELF_PATH_DIR}. many times, so that the string takes the real path to the files (/Users/karlsd/dotfiles/.path, etc.).
Is there any way to make it simpler? For example, to add /Users/karlsd/dotfiles/. to each item before the loop?