Bug 64034

Summary: Shell scripts fail if space in JAVA_HOME path
Product: JMeter Reporter: ray7219+apache
Component: MainAssignee: JMeter issues mailing list <issues>
Severity: normal CC: p.mouawad
Priority: P2 Keywords: FixedInTrunk
Version: 5.2.1   
Target Milestone: JMETER_5.3.0   
Hardware: All   
OS: All   
Attachments: File bin/jmeter with proposed fix
File bin/jmeter.sh with proposed fix

Description ray7219+apache 2019-12-26 14:43:07 UTC
Created attachment 36931 [details]
File bin/jmeter with proposed fix

Both bin/jmeter and bin/jmeter.sh fail at line 128 respectively line 98 with a:
  [: : integer expression expected
This is caused by not being able to run the java executable to obtain the Java version.
Root cause lies at lines: 91+92 respectively 61+62 which set the JAVA_PATH and JRE_HOME environment variables by running dirname. The argument given to dirname is not encapsulated in quotes which results in dirname receiving two (or more) arguments in case JAVA_PATH contains spaces. This can easily be fixed by adding quotes:
      JAVA_PATH=`dirname "$JAVA_PATH" 2>/dev/null`
      JRE_HOME=`dirname "$JAVA_PATH" 2>/dev/null`

Attached are the fixed files
Comment 1 ray7219+apache 2019-12-26 14:44:23 UTC
Created attachment 36932 [details]
File bin/jmeter.sh with proposed fix
Comment 2 Felix Schumacher 2019-12-26 15:20:31 UTC
Thanks for the report.

The fix is committed and will be included in the next release.

It would be nice, if you could check, whether the fix helps with your setup. You can use the next nightly, if you don't want to build JMeter from source.

If you think the fix is OK, than you can close this report.

For future reports, it would be nicer to attach patches rather than complete files. It makes reasoning about the changes easier. Although in this case, the description was really clear, so it didn't matter.

commit 9ddf0d961b9edfb09dfc95c0e6569f8559e0e860
AuthorDate: Thu Dec 26 16:14:50 2019 +0100

    Shell scripts fail if space in JAVA_HOME path
    Contributed by ray7219
    Bugzilla Id: 64034
 bin/jmeter        | 4 ++--
 bin/jmeter.sh     | 4 ++--
 xdocs/changes.xml | 2 ++
 3 files changed, 6 insertions(+), 4 deletions(-)
Comment 3 ray7219+apache 2019-12-26 16:24:38 UTC
Tested change, works fine for me.
Ticket closed.
Thank you

Wrt. Attaching patches: will do.