git post receive hooks运行远程服务器shell脚本错误期待keyword_do

问题描述 投票:0回答:2

在以下帖子接收挂钩后,我推送到存储库,remote: hooks/post-receive:: syntax error, unexpected $undefined, expecting keyword_do or '{' or '('后得到错误

发布接收脚本如下,

#!bin/bash while read oldrev newrev ref \ do ssh user1@ip -pPassword\ 'path/to/the/shell.sh' end

在这种情况下,我的远程服务器paswd包括\,我尝试如下

#!bin/bash while read oldrev newrev ref do ssh user1@ip -pPassword\ 'path/to/the/shell.sh' end

#!bin/bash while read oldrev newrev ref \ do (ssh user1@ip -pPassword\ 'path/to/the/shell.sh'); end

git shell githooks
2个回答
0
投票

对于bash中的while循环,您可以:

#!/bin/bash
while read oldrev newrev ref;do
    echo $read $oldrev $newrev $ref
done

要么

#!/bin/bash
while read oldrev newrev ref
do
    echo $read $oldrev $newrev $ref
done

要么

#!/bin/bash
while read oldrev newrev rev;do echo $read $oldrev $newrev $ref;done

我不确定ssh部分是否正确,但我不认为\是必要的。


0
投票

我不确定ssh部分是否正确

实际上,ssh可能会起作用,但却成为问题的一部分:

  • 从post-receive hook所在的服务器执行时检查ssh -T user1@ip -pPassword是否正常工作
  • 检查它是否以静默方式工作,这意味着user1 .bashrc.profile不会回显一串字符串,这可能会干扰挂钩执行。
© www.soinside.com 2019 - 2024. All rights reserved.