因此,我正在調整我的 dotfiles 以自動安裝包,并且我想自動檢測安裝腳本是否正在Gitpod作業區中運行。這就是我目前所擁有的:
if is-executable "gp"; then
echo "Gitpod detected, not installing <pre-installed package>"
else
# Continue with installation... rest of code goes here
fi
我知道這gp是 Gitpod 中可用的命令,因為它是 CLI 并且上面的代碼作業正常,但它并不理想,假設其他包也有gpGitpod 之外的命令(盡管我不使用它們)。那么,檢測 Bash 腳本是否在 Gitpod 中運行的更好方法是什么?
uj5u.com熱心網友回復:
您可以在此處的代碼段中使用此功能:
function is::gitpod() {
# Check for existent of this gitpod-specific file and the ENV var.
test -e /ide/bin/gitpod-code && test -v GITPOD_REPO_ROOT;
}
此外,如果您有興趣了解可能的情況,請查看我的dotfiles,它已經在做您想做的事情,甚至更多:)
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/491442.html
下一篇:kornshell中的例外處理
