The current Runtime.exec(String cmd) uses wrong parser for command line. For
example. If given the comamnd line is exactly as below.
child.exe "a b"
Note there are two spaces between a and b. This command line will be parsed
into args like
argv[0] = "child.exe";
argv[1] = "\"a";
argv[2] = "b\"";
When these arguments are catenated together, what we got it
child "a b"
now, we have only one space between a and b. But there is only one space between
a and b in the orignal command line, we will lucky to get back the original one.
If it is on unix, we are totally screwed up. The child process will get 3
arguements instead of 2.
example. If given the comamnd line is exactly as below.
child.exe "a b"
Note there are two spaces between a and b. This command line will be parsed
into args like
argv[0] = "child.exe";
argv[1] = "\"a";
argv[2] = "b\"";
When these arguments are catenated together, what we got it
child "a b"
now, we have only one space between a and b. But there is only one space between
a and b in the orignal command line, we will lucky to get back the original one.
If it is on unix, we are totally screwed up. The child process will get 3
arguements instead of 2.
- relates to
-
JDK-4111881 (process) Runtime.exec() command line parsing has unacceptable behavior on all platform
- Closed
-
JDK-6405688 Need ProcessBuilder methods for String command argument, like exec().
- Closed