簡體   English   中英

“-bash:[git:找不到命令”在mac上的bash腳本中

[英]"-bash: [git: command not found " in bash script on mac

我正在創建一個 bash 腳本來執行 git 命令。 在一個函數中,我在 git status 上使用 if 語句:

if [[ `git status --porcelain` ]]; then
    echo "has change"
else
    echo "no"
fi

然后它給出了這個錯誤:

-bash: [git: command not found

git 在命令行中工作得很好。 在沒有 if 語句的情況下,它在我的其他函數中也能正常工作。

-bash: [git: 命令未找到

此錯誤表明您的[和命令的其余部分之間沒有空格,如下面的屏幕截圖所示(第 1 行沒有空格)

在此處輸入圖片說明

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM