I want to separate a variable from my main script file. This variable contains a path to another script:
PATH_TO_SCRIPT="/tmp/script_folder/"
I put this variable into a separate file called "config.sh".
In my main script, I source this file to get the path and use it this way:
source "config.sh"
echo $PATH_TO_SCRIPT
result=$($PATH_TO_SCRIPT/script.bash)
But I get the following result:
/tmp/script_folder/
/tmp/script_folder/script.bash: No such file or directory
If I don't source the file and explicitly put the variable into the main script this way, it is working:
#source "config.sh"
PATH_TO_SCRIPT="/tmp/script_folder/"
echo $PATH_TO_SCRIPT
result=$($PATH_TO_SCRIPT/script.bash)
I don't get it.. I can see that the path when sourced is well retrieved (the echo prouves it) but then I cannot use the path. I imagine my problem comes from the using of $(command) but I don't get why. Maybe a story with subshell etc. ? I don't get how to go over this error.