【问题标题】:Error when running a script运行脚本时出错
【发布时间】:2015-01-31 06:02:51
【问题描述】:

我有以下 capistrano 脚本(为简单起见重新缩进):

sh -c 
    'git clone -q git@github.com:naorye/WebDevEasy-Wordpress.git /home1/webdevea/public_html/staging/shared/cached-copy &&
    cd /home1/webdevea/public_html/staging/shared/cached-copy &&
    git checkout -q -b deploy e508df390778be1d6ce4c4f7ceb71db149fa8f77 &&
    git submodule -q init &&
    git submodule -q sync &&
    export GIT_RECURSIVE=$([ ! \"`git --version`\" \\< \"git version 1.6.5\" ] && echo --recursive) &&
    git submodule -q update --init $GIT_RECURSIVE;'

此代码由 WP-stack 生成:https://github.com/markjaquith/WP-Stack
在远程机器上运行时,出现错误:

-bash: "git: No such file or directory

调试时(逐行运行),我看到出错的行是:

export GIT_RECURSIVE=$([ ! \"`git --version`\" \\< \"git version 1.6.5\" ] && echo --recursive)

有什么问题?我该如何解决?

【问题讨论】:

  • 可以修改脚本吗?

标签: wordpress git unix ssh capistrano


【解决方案1】:

我不确定脚本是如何生成的,但似乎有一些不必要的转义。我清理了它,以下对我有用:

export GIT_RECURSIVE=$([ ! "`git --version`" \< "git version 1.6.5" ] && echo --recursive) &&

【讨论】: