I wanted to export variables based on the condition as:
if [[ "$1" == *"eu"* ]]; then
export API_URL=https://xx-gateway-eu.xx.com/cccccccc
elif [[ "$1" == *"as"* ]]; then
export API_URL=https://xx-gateway-as.xx.com/cccccccc
else
export API_URL=https://xx-gateway-na.xx.com/cccccccc
fi
When i execute the script using "./script.sh yyy.ee.kkk.eu.dd.com", it got executed successfully but i dont see the variable got exported, echo $API_URL is empty. Could see the variable is set if i use 'source ./script.sh' and i understand the reason why its behaving like this. But, is there a way to achieve it as part of the shell script execution itself and without using source?