I have some code that looks like this:
################### - Let's call this section 1
if [ -n "$STUFF_JAVA" ]; then
__LAUNCHER="$STUFF_JAVA"
else
__LAUNCHER="java"
fi
################### - Let's call this section 2
if [ -n "$JAVA_HOME" ]; then
# # echo "DEBUG: Using JAVA_HOME"
_STUFF_JAVA_HOME="$JAVA_HOME"
_STUFF_JAVA="$_STUFF_JAVA_HOME"/bin/$__LAUNCHER
else
echo "testing"
fi
############## - Let's call this section 3
_STUFF_JAVA_HOME="$JAVA_HOME"
_STUFF_JAVA="$_STUFF_JAVA_HOME"/bin/$__LAUNCHER
##############
I don't understand why section 2 has issues setting the _STUFF_JAVA_HOME variable but section 3 does not? Do I need to use curly brackets or parenthesis somewhere?
I want my code to set the following variables:
_STUFF_JAVA_HOME
_STUFF_JAVA
I don't understand why it gets set in section 3 but not section 2.
For some reason, in section 2, it's not able to pick up the variable to determine the length...
Is there something I am missing?
(I am inexperienced with shell script. I am reading a book and have literally finished chapter 1.)
_STUFF_JAVA_HOME
and then uses the uninitialized_PENTAHO_JAVA_HOME
. How is that supposed to work? – Hans-Martin Mosner Jun 12 '23 at 20:04