I'm using the svn
command from Java to get info about a working copy.
final Process exec = Runtime.getRuntime().exec(
new String[]{"svn","info","--xml","/path/to/wc"}
);
ByteStreams.copy(exec.getErrorStream(), System.err);
// ... more code to read output
This gives the error output
/path/to/wc
: (Not a versioned resource)
However, if I run the same command in a terminal window, I get the output I want. I also tried to rule out the environment when running in a terminal:
env -i svn info --xml /path/to/wc
But the output is still correct. Why does it behave differently when run from Java?
The real /path/to/wc
had a newline at the end of it. If I were more familiar with SVN error output, I could have seen it:
/path/to/wc
: (Not a versioned resource)
Note the newline before the :
I accidentally found this by replacing an earlier exec("readlink -m " + path)
by the pure Java path.getCanonicalName()
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.