Capistrano 3.在服务器上设置bash shell而不是csh

the*_*her 5 shell capistrano3 sshkit

当cap3尝试在我的FreeBSD服务器上执行命令时 - 我有错误,我的cap3任务不起作用

DEBUG [0bb99d53] Command: if test ! -d /home/web_server/data/www/capistrano/site/shared/dumps; then echo "Directory does not exist '/home/web_server/data/www/capistrano/site/shared/dumps'" 1>&2; false; fi
DEBUG [0bb99d53]    if: Expression Syntax.
DEBUG [0bb99d53]    fi: Command not found.
Run Code Online (Sandbox Code Playgroud)

我知道为什么 - 因为我的服务器默认使用csh shell

% echo $0
-csh
Run Code Online (Sandbox Code Playgroud)

以下cap3变量对我不起作用

set :shell, '/usr/local/bin/bash'
set :default_shell, '/usr/local/bin/bash'
Run Code Online (Sandbox Code Playgroud)

如何为cap3任务设置shell?

tcs*_*aru 0

我的意见是你可以尝试使用:

/bin/bash -c 'if test ! -d /home/web_server/data/www/capistrano/site/shared/dumps; then echo "Directory does not exist \'/home/web_server/data/www/capistrano/site/shared/dumps\'" 1>&2; false; fi'
Run Code Online (Sandbox Code Playgroud)

来自 Bash 手册页:

如果存在 -c 选项,则从字符串中读取命令。如果字符串后面有参数,它们将被分配给位置参数,从 $0 开始。

我做了一个测试,它对我有用:

1@one:~>%bash -c "/bin/echo Hello; echo Goodbye"
Hello
Goodbye
Run Code Online (Sandbox Code Playgroud)