jmeter-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Philippe Mouawad <philippe.moua...@gmail.com>
Subject Re: Questions about bin/jmeter and java version detection
Date Sat, 04 Nov 2017 18:49:27 GMT
go for your proposal , it will be more clear

On Saturday, November 4, 2017, Felix Schumacher <
felix.schumacher@internetallee.de> 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.

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message