I have simplified the problem by removing domain-specific details to be easier to be reproduced.
I have a file called items that has the following content:
itemA
itemB
And two other files called itemA.settings and itemB.settings that have the following content:
itemA.settings content
export title="Title itemA"
itemB.settings content:
export title="Title itemB"
I have created a script(configure-all-items.sh) that reads the content from items file and loops through each element like below:
#!/bin/bash
$itemListDIR="../path"
itemList=$(cat $itemListDIR/items);
for(item in itemList)
do
echo "Configuring item: $item"
prepare-item.sh $item
done
prepare-item.sh uses the title to create a file for each item with the title as filename. The content of the prepare-item.sh is like below:
#!/bin/bash
$item="$1"
source "$item.settings"
echo "Item has title: $title" > title.txt
When executing the configure-all-items.sh script two files are created:
Title itemA.txt
that the content:
Item has title:
Title itemB.txt that has the content:
Item has title: Title itemB
Also, I get this error when itemA.settings
is being sourced
No such file or directoryline xx: ./../../../itemA