I am writing a simple script that export variables based on condition. But after running the script none of the variables are accessible. The code is as follows:
#!/bin/bash
if [[ $1 == 11 ]]; then
echo "Loading java 11"
export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk-11.0.11.jdk/Contents/Home"
else
echo "Loading java 8"
export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_201.jdk/Contents/Home"
fi
I am running with ./file.sh 11 and bash file.sh 11 but both echo Loading 11 but does not load.