Reputation: 791
There's a bash script on my linux machine with these two lines:
[ -r /etc/java/java.conf ] && . /etc/java/java.conf
export JAVA_HOME
What does the export JAVA_HOME do? Usually I thought export VARIABLE_NAME=something sets the variable to something.
What does running export JAVA_HOME without setting it to something do?
I tried running it on the commandline, but nothing happens.
Upvotes: 3
Views: 2330
Reputation: 47229
The two lines of code (better to use double brackets):
[[ -r /etc/java/java.conf ]] && . /etc/java/java.conf
export JAVA_HOME
...equates to this:
-r
checks if /etc/java/java.conf
exists and read permission is granted.
&&
if the condition above is true then source the file.
export JAVA_HOME
takes the previously-assigned value of $JAVA_HOME
from the sourced file making it available to subprocesses rather than only within the shell.
Upvotes: 6