I'm writing a script to start a java program on both Windows and Linux. It needs to use a config file as I will have both batch files (on Windows) and shell scripts (on Linux).
The config file (cmd.config):
CUSTOM_JAVA_HOME=""
JAVA_FLAGS="-server -Xmx2048M"
In my batch file, I load it like this:
if exist cmd.config for /F "delims=" %%A IN (cmd.config) DO SET %%A
and in my shell script, I simply use:
if [ -f "cmd.config" ]; then
. "./cmd.config"
fi
Now, I want to add comments to the file, in shell format, like so:
# Set a custom java home with no trailing slash. Example: /home/javahome or C:\javahome
CUSTOM_JAVA_HOME=""
JAVA_FLAGS="-server -Xmx2048M"
That would work just fine in my shell script (on Linux), but breaks in my batch file (on Windows) as it tries to do a SET for that comment line.
How can I skip those lines starting with #
in the FOR
loop in the batch file (on Windows)?