Hi,
I'm trying to write a Bash script that checks if a specific environmental variable exists, and if not, prompts the user as to what they want its value to be.
I'm using the environmental variable to store the path to a program the user is expected to have installed. If my script does not find it, it will write the path the user inputs to the environmental variable it will use each time it's executed.
Here's what I've come up with:
Code:
if [ -z $The_Path ]; then
echo -n "The_Path not found, enter a value: "
read The_Path
export The_Path
else
echo $The_Path
fi
(the -z argument returns boolean true if the string has 0 characters)
For some reason, each time this script runs, the environmental variable is detected to be empty and (obviously) never writes the variable permanently.
Is there something I'm overlooking?