+1 for your fix
On Saturday, November 4, 2017, Felix Schumacher <
[email protected]> wrote:
> Am Samstag, den 04.11.2017, 19:49 +0100 schrieb Philippe Mouawad:
> > go for your proposal , it will be more clear
>
> Done. Now I have a followup question.
>
> We will execute java from JAVA_HOME (or JRE_HOME), but will evaluate
> the version of java from the executable in the path. That looks like a
> bug to me.
>
> I think we should change that line 73 to
>
> "${JAVA_HOME}/bin/java" -version ....
>
> Regards,
> Felix
>
> >
> > On Saturday, November 4, 2017, Felix Schumacher <
> > [email protected] <javascript:;>> wrote:
> >
> > >
> > > Hi all,
> > >
> > > in bin/jmeter from line 73 we have the following code:
> > >
> > >
> > > CURRENT_VERSION=`"$_java" -version 2>&1 | awk -F'"' '/version/
> > > {print
> > > $2}'`
> > > # Check if version is from OpenJDK or Oracle Hotspot JVM prior to 9
> > > containing 1.${version}.x
> > > if [ ${#CURRENT_VERSION} -lt 1 ]; then
> > > CURRENT_VERSION=`echo $CURRENT_VERSION | awk -F'.' '{ print $2
> > > }'`
> > > else
> > > MINIMAL_VERSION=`echo $MINIMAL_VERSION | awk -F'.' '{ print $2
> > > }'`
> > > fi
> > >
> > > # Check if Java is present and the minimal version requirement
> > > if [ $CURRENT_VERSION -gt $MINIMAL_VERSION ]; then
> > > ADD_MODS="--add-modules java.activation"
> > > fi
> > >
> > > I wonder, what line 75 (${#CURRENT_VERSION} -lt 1) should do. In
> > > bash
> > > (and probably most other shells) ${#VAR} will count the characters
> > > in a
> > > "normal" variable.
> > >
> > > If that number is less than one, it is equivalent to an empty
> > > variable.
> > > In other places of this script we use either '-z "${VAR}' or
> > > '"x$VAR"
> > > != "x"' for such purpose.
> > >
> > > But I believe it is not what we wanted here, as the next line uses
> > > the
> > > variable to pipe it through awk, which makes no sense, if it is
> > > really
> > > empty.
> > >
> > > What is the purpose of this if statement in line 75?
> > >
> > > I believe it would probably be simpler to remove "1." from the
> > > start of
> > > the version string and every not number from the number after that.
> > > That way we would have a computed version of 8 for java 8 (1.8.x_x)
> > > and
> > > 9 for java 9 (9-x)
> > >
> > > Something like:
> > >
> > > for v in 9-ea 1.8.121_91; do
> > > echo $v | awk '{gsub("^1.", ""); gsub("[^0-9].*$", ""); print $1}'
> > > done
> > >
> > > Regards,
> > > Felix
> > >
> >
>
--
Cordialement.
Philippe Mouawad.