I am using shell script to call a java program. When calling passing java program I am passing -Dargument which has a path to a directory. This -D argument is read from a file. Now I am facing a issue when this path contains spaces. I tried with quote and also with escaping quotes but both dint work.
Here is my shell script code, test.sh
D_ARG=`(tr '\r\n' ' ' < argument.dat)
\#executing java code by passing above argument
java ${D_ARG} TestProgram
Below is my argument file, argument.dat
-Dargument1="/Path /To A/File"
When I set the echo on using set -x, I see the shell converting it to
'-Dargument1="/Path' '/To' 'A/File"'
Where it adds single quotes when it encounters spaces and I get "/To" class not found exception. How to resolve this issue. Any suggestion or help will be really appreciable.