Bug 64501 - The catalina.sh script is returning a "bad substitution" error and exiting
Summary: The catalina.sh script is returning a "bad substitution" error and exiting
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 9
Classification: Unclassified
Component: Catalina (show other bugs)
Version: 9.0.35
Hardware: Sun Solaris
: P2 normal (vote)
Target Milestone: -----
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-06-06 17:00 UTC by Pete Pocius
Modified: 2020-06-09 20:19 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Pete Pocius 2020-06-06 17:00:59 UTC
We are in the process of upgrading from Tomcat version 9.0.31 to 9.0.35.  When starting Tomcat version 9.0.35 on a Solaris UNIX system, the catalina.sh script is returning a "bad substitution" error and exiting.  It appears the following "if statement" in the script is causing the error:

if [ "${LOGGING_CONFIG#*-D}" != "$LOGGING_CONFIG" ]; then

Can someone look into this bug?

Thank you
Comment 1 Christopher Schultz 2020-06-06 18:16:59 UTC
What is your /bin/sh actually running?
Comment 2 Michael Osipov 2020-06-06 21:07:34 UTC
On some Solaris versions the Bourne shell is not fully POSIX compliant. I assume that our script is proper POSIX compliant. This parts seems to be: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html
Comment 3 Pete Pocius 2020-06-06 22:40:13 UTC
(In reply to Michael Osipov from comment #2)
> On some Solaris versions the Bourne shell is not fully POSIX compliant. I
> assume that our script is proper POSIX compliant. This parts seems to be:
> https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html

Hi Michael,

Thanks for the reply.  It looks like on our version of Solaris (Sun version 10), the default Bourne shell is not fully POSIX compliant as you mentioned.  When I change the #!/bin/sh to #!/usr/xpg4/bin/sh the script works.  Based on this, will we just have to adjust the script to use that version of the Bourne shell going forward, or will a change be made to that "if statement" to handle both POSIX and non-POSIX compliant systems?

Thanks,
Pete Pocius
Comment 4 Michael Osipov 2020-06-06 22:54:15 UTC
(In reply to Pete Pocius from comment #3)
> (In reply to Michael Osipov from comment #2)
> > On some Solaris versions the Bourne shell is not fully POSIX compliant. I
> > assume that our script is proper POSIX compliant. This parts seems to be:
> > https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html
> 
> Hi Michael,
> 
> Thanks for the reply.  It looks like on our version of Solaris (Sun version
> 10), the default Bourne shell is not fully POSIX compliant as you mentioned.
> When I change the #!/bin/sh to #!/usr/xpg4/bin/sh the script works.  Based
> on this, will we just have to adjust the script to use that version of the
> Bourne shell going forward, or will a change be made to that "if statement"
> to handle both POSIX and non-POSIX compliant systems?

The question is what is suitable alternative for ${parameter#word}? Bourne shell on Solaris 10 doesn't support $(command) either.
Comment 5 Mark Thomas 2020-06-09 13:40:28 UTC
We might be able to do something with "case". It is used elsewhere in catalina.sh for pattern matching.
Comment 6 Pete Pocius 2020-06-09 13:53:53 UTC
(In reply to Mark Thomas from comment #5)
> We might be able to do something with "case". It is used elsewhere in
> catalina.sh for pattern matching.

Hi Mark,

For now, we've commented-out the block of code checking for deprecated logging, and the script runs successfully.  I'll leave it up to you whether or not you want to do something with "case".

Thanks,
Pete Pocius
Comment 7 Mark Thomas 2020-06-09 13:57:59 UTC
I'd like to fix it if we can.

"#*-D" is really a "contains" test, not a "starts with" test. We'd need to drop the "*" to get a "starts with" test. Currently investigating case an alternative.
Comment 8 Mark Thomas 2020-06-09 19:30:05 UTC
Confirmed. Case works on Solaris 10. I'll switch the code to that.
Comment 9 Mark Thomas 2020-06-09 20:15:17 UTC
Thanks for the report.

Fixed in:
- 9.0.x for 9.0.37 onwards
- 8.5.x for 8.5.57 onwards
- 7.0.x for 7.0.105 onwards

10.0.x was not affected.
Comment 10 Pete Pocius 2020-06-09 20:19:14 UTC
(In reply to Mark Thomas from comment #9)
> Thanks for the report.
> 
> Fixed in:
> - 9.0.x for 9.0.37 onwards
> - 8.5.x for 8.5.57 onwards
> - 7.0.x for 7.0.105 onwards
> 
> 10.0.x was not affected.

Hi Mark,

Thanks for taking care of that!