Hook脚本执行期间出错

时间:2011-12-13 05:53:04

标签: svn tortoisesvn

如果我倾向于执行以下脚本

#!/bin/sh

REPOS=”$1"
TXN=”$2"

# Make sure that the log message contains some text.
SVNLOOK=/usr/local/bin/svnlook
LOGMSG=`$SVNLOOK log -t “$TXN” “$REPOS” | find  *.cpp |grep “[a-zA-Z0-9]” | wc -c`

if [ "$LOGMSG" -lt 10 ]; then
echo -e “Please provide a meaningful comment when committing changes.” 1>&2
exit 1
fi

我遇到以下错误:

D:\pg\trunk\pg.txt
D:\pg\trunk\pg.txt
Commit failed (details follow):
'pre-commit' hook failed with error output:
find: *.cpp: No such file or directory
svnlook: Can't open file 'svnrepos2/SVN_Scripts_POC./format': No such file or
 directory
.Please provide a meaningful comment when committing changes.
completed!

为什么我会收到提交消息呢?

1 个答案:

答案 0 :(得分:0)

你的LOGMSG变量捕获标准输出(标准输出),而不是stderr。

如果找不到.cpp,您的标准输出将为空,您的情况将始终通过。

首先需要检查是否有.cpp个文件(例如,[ "$?" = "0" ]将测试find命令的结果),然后一旦捕获{{1输出,继续进行find和测试。