【发布时间】:2019-05-16 09:23:40
【问题描述】:
我正在尝试创建一个我需要在机器上安装supervisord 的基本实用程序。但问题是它取决于用户,他/她如何安装它,所以在这里我试图涵盖几乎所有场景以获取 supervisord 命令。
以下是我现在正在使用的代码。
if [[ -f "/opt/anaconda/bin/supervisord" ]]; then
RUNNER="/opt/anaconda/bin/supervisord"
elif [[ -f "/usr/local/bin/supervisord" ]]; then
RUNNER="/usr/local/bin/supervisord"
elif [[ -f "/usr/bin/supervisord" ]]; then
RUNNER="/usr/bin/supervisord"
elif [[ "$(command -v supervisord)" ]]; then
RUNNER="supervisord"
else
echo "supervisord is not install on this machine"
exit 1
fi
我正在寻找更好的方法来实现这一目标。
【问题讨论】:
-
您应该只要求用户配置他们的
PATH,以便它包含带有supervisord的目录。 -
你可以使用
for循环遍历所有可能的值,然后在里面使用if/break。 -
@Barmar 我正在尝试创建一个解决方案,我不想要求用户为其配置任何内容。只需在他们的机器上安装
supervisord。 -
@yeputons,遍历所有路径也差不多。
-
你现在的代码有什么问题?
标签: linux bash shell supervisord