【发布时间】:2013-02-11 21:59:33
【问题描述】:
我正在用 GIT 编写一个接收后脚本。
我附上了它的最小版本,它也失败了:
generate_email()
{
for user in $(git config --get-all notifications.users); do
unset files_to_notify
for filter in $(git config --get-all notifications.$user); do
files_to_notify=" $files_to_notify $(git diff-tree --no-commit-id \
--name-only -r $newrev | grep $filter) "
done
files_to_notify=( $files_to_notify )
if [ -n "$files_to_notify" ]; then
echo ${files_to_notify[*]}
fi
done
}
while read oldrev newrev refname
do
generate_email $oldrev $newrev $refname
done
当我尝试在调用此脚本时推送到 git 服务器时,我收到以下消息:
remote: hooks/post-receive: 10: hooks/post-receive: Syntax error: "(" unexpected (expecting "done")
当我尝试在命令行中运行它时,脚本可以正常工作而没有此消息。
有什么想法吗?
谢谢,
埃利亚希夫
【问题讨论】:
-
那么
files_to_notify=( $files_to_notify )应该做什么?