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/wchad a newline at the end of it. If I were more familiar with SVN error output, I could have seen it:Note the newline before the
:I accidentally found this by replacing an earlier
exec("readlink -m " + path)by the pure Javapath.getCanonicalName().