Bug 64034 - Shell scripts fail if space in JAVA_HOME path
Summary: Shell scripts fail if space in JAVA_HOME path
Status: RESOLVED FIXED
Alias: None
Product: JMeter - Now in Github
Classification: Unclassified
Component: Main (show other bugs)
Version: 5.2.1
Hardware: All All
: P2 normal (vote)
Target Milestone: JMETER_5.3.0
Assignee: JMeter issues mailing list
URL:
Keywords: FixedInTrunk
Depends on:
Blocks:
 
Reported: 2019-12-26 14:43 UTC by ray7219+apache
Modified: 2020-03-15 14:37 UTC (History)
1 user (show)



Attachments
File bin/jmeter with proposed fix (8.39 KB, application/x-shellscript)
2019-12-26 14:43 UTC, ray7219+apache
Details
File bin/jmeter.sh with proposed fix (3.77 KB, application/x-shellscript)
2019-12-26 14:44 UTC, ray7219+apache
Details

Note You need to log in before you can comment on or make changes to this bug.
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.
Comment 4 The ASF infrastructure team 2022-09-24 20:38:18 UTC
This issue has been migrated to GitHub: https://github.com/apache/jmeter/issues/5218