[英]SVN Info command different when run from Java than in terminal
I'm using the svn
command from Java to get info about a working copy. 我正在使用Java的
svn
命令来获取有关工作副本的信息。
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?
从Java运行时,为什么其行为有所不同?
The real /path/to/wc
had a newline at the end of it. 实际的
/path/to/wc
在其末尾有换行符。 If I were more familiar with SVN error output, I could have seen it: 如果我对SVN错误输出更加熟悉,我可能会看到:
/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()
. 我通过用纯Java
path.getCanonicalName()
替换了较早的exec("readlink -m " + path)
意外发现了这一点。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.