我有一个应该可以重新运行的 bash 脚本。这包括
pecl install foo ||
{
echo "Could not install foo!";
exit 1;
}
Run Code Online (Sandbox Code Playgroud)
如果这运行两次,它会出错
pecl/foo is already installed and is the same as the released version 1.2.3
install failed
Could not install foo!
Run Code Online (Sandbox Code Playgroud)
与 apt-get 或 yum 等工具不同,如果模块已安装,pecl 会返回错误代码,而我希望它报告成功。
我可以捕获和 grep stdout/stderr 但是有没有更简单的方法来实现相同的目标?
if ! pecl list | grep foo >/dev/null 2>&1;
then
pecl install foo ||
{
echo_err "Could not pecl install foo";
exit 1;
}
fi
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1365 次 |
最近记录: |