So I was a bit late to this and the solution has been provided, but I thought I would add for others who may come across thread:
1. Whenever unsure about exactly what you script is doing, first rule of thumb should be to use - - set -xv - - this would have identified what exactly was being passed to find (in this case)
2. The use of a for loop to read through items may be an issue if word splitting could be involved, so a while loop would have been better (here we would assume the OP can guarantee no spaces or such in the path to file)
3. A for loop will only populate the variable with items from the list provided, so a test to check if the variable is empty will never be true - - if [ -z "${loc}" ]
4. Additional quotes around the variable being sourced are redundant and may well cause similar issues to those found previously with find - - source "\"${loc}\""
5. Unless being worried about Posix compliance or running on a much older version of bash, one should favour [[]] over [] (list of differences can be found
here)
6. Not knowing when the include function will be called, this is a just in case message. Should the function receive more than 255 parameters, the exit function at the end of the loop will hit the below issue:
Quote:
If n is specified, but its value is not between 0 and 255 inclusively, the exit status is undefined.
|