Word Splitting
I was about ready to pull my hair out today when I couldn't figure out why my startup script wasn't letting me pass options to Java in cygwin.
Here's what I was trying to do:
<geshi lang="bash"> JAVA_CMD="$JAVA_HOME/bin/java" export JAVA_HOME JAVA_OPTS="-ea -server" export JAVA_OPTS
- ...
"$JAVA_CMD" ${JAVA_OPTS} -Dbash=fun com.MyClass </geshi>
Whenever I would start my script, I would get this error: <geshi lang="bash"> Unrecognized option: -ea -server Could not create the Java virtual machine. </geshi>
If I changed JAVA_OPTS to only "-ea" or "-server" it worked fine. I tried every combination of quoting my command, and I could not get it to work. I thought I was going crazy, because I've used this pattern in a dozen or so scripts, and the default JBoss script uses the same. Then, I found the section of the Bash manual on word splitting. I did a quick grep, and found sure enough, someone thought to change this inside the script.
<geshi>
- Unset Intercommand separator
IFS= export IFS </geshi>
This apparently was someone else's workaround, so they didn't have to quote "$JAVA_CMD"
and any options with spaces in them.