首页 > 解决方案 > git post receive hooks run remote server shell script error expecting keyword_do

问题描述

在以下帖子接收钩子下,我推送到存储库后确实收到错误, 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

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

#!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

标签: gitshellgithooks

解决方案


对于whilebash 中的循环,您可以:

#!/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部分是否正确,但我认为没有\必要。


推荐阅读