I'm sure the title doesn't help much.
Here is what we've broken this down to:
Here is a little script called "printargs.sh" I'm using to test this:
#! /bin/sh
echo "1[$1] 2[$2]"
I have an environment variable which has a quoted string that needs to be preserved across shell invocations so that it's considered a single parameter.
Here is some shell history:
$ VAR_A="foo bar"
$ VAR_B="\"foo bar\""
$ VAR_C="'foo bar'"
$ sh printargs.sh "$VAR_A"
1[foo bar] 2[]
$ sh printargs.sh $VAR_B
1["foo] 2[bar"]
$ sh printargs.sh $VAR_C
1['foo] 2[bar']
$
The key is what gets printed for the VAR_B and VAR_C cases. The shell treats those quote characters as ordinary characters.
The real use case has a variable set in a file with a value like this:
"-XX:OnError=\"coreDumpHandler.sh %p\" -Dloader.path=/opt/ajsc/etc/config/"
This eventually gets set into an environment variable and is passed to a java command line. This fails because java thinks that "%p" is the class name to run. That clearly means it's losing the quoting structure. If I manually change the script that references that environment variable, and instead just add this to the command line:
-XX:OnError="coreDumpHandler.sh %p"
it works fine. I need to be able to specify the additional command-line parameters in that properties file, which gets passed into the environment variable. It's not practical to hardcode that string in the script that references the environment variable.
We originally saw this in an Alpine image, but I've verified it in Ubuntu also.