Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/svn/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cassandra/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
svn日志--xml无效的xml_Svn - Fatal编程技术网

svn日志--xml无效的xml

svn日志--xml无效的xml,svn,Svn,我使用svn log--xml响应查看特定修订版的更改。但如果版本或路径无效,我只想得到一个空白但有效的xml响应。有可能吗 因此,与此相反: <?xml version="1.0"?> <log> svn: Unable to find repository location for 'http://subversion.ny.jpmorgan.com /svn/repos/IM_RPS_CORE/rps_deploy_tools_content_test/branch

我使用
svn log--xml
响应查看特定修订版的更改。但如果版本或路径无效,我只想得到一个空白但有效的xml响应。有可能吗

因此,与此相反:

<?xml version="1.0"?>
<log>
svn: Unable to find repository location for 'http://subversion.ny.jpmorgan.com /svn/repos/IM_RPS_CORE/rps_deploy_tools_content_test/branches/rol-201106-content-test' in revision 1556

svn:找不到“”的存储库位置http://subversion.ny.jpmorgan.com /svn/repos/IM_RPS_CORE/RPS_deploy_tools_content_test/branchs/rol-201106-content-test,修订版1556
我可以得到:

<?xml version="1.0"?>
<log>
</log>


谢谢

检查命令的错误代码,不要尝试解析其输出或生成空XML。大概是这样的:

#!/bin/bash

FILE=svn_log.xml
svn log --xml > "${FILE}" 2>/dev/null
RET=$?

if [ $RET -ne 0 ]; then
(cat <<EOF
<?xml version="1.0"?>
<log>
</log>
EOF
) > "${FILE}"

fi

cat "${FILE}"
#/bin/bash
FILE=svn_log.xml
svn日志--xml>“${FILE}”2>/dev/null
RET=$?
如果[$RET-ne 0];然后
(catNo can do

但是,如果检查
svn log
命令的退出状态代码,则可以自己处理该问题。例如,在Bash shell脚本中:

if ! svn log --xml $url > $xmlOutput 2> /dev/null
then
     cat > $xmlOutput <<EOF
<?xml version="1.0"?>
<log>
</log>
EOF
fi
if!svn log--xml$url>$xmlOutput 2>/dev/null
然后
cat>$xmlOutput