Bash 腳本建置腳本錯誤。第 20 行:意外標記「fi」附近出現語法錯誤

Bash 腳本建置腳本錯誤。第 20 行:意外標記「fi」附近出現語法錯誤

在我的 bash 腳本中,我收到一個錯誤:

./buildscriptbuild.sh: line 20: syntax error near unexpected token 'fi'

我已經在本機系統中測試了以下 bash 腳本。任何人都可以在這方面幫助我。提前致謝。

#!/bin/sh

cd /home/ec2-user/inoutserver
if git pull origin development; then
    if npm install; then
        if grunt build --force; then
            echo "build success"
        else
            if sudo cp -r dist/* /home/ec2-user/testfolder; then
                echo "deployment success!"
            fi
            else
            echo "deployment failed"
        fi
    else
        echo "build failed"
    fi
else
    echo "npm install failed"
fi

答案1

中間替換這個:

        fi
        else
        echo "deployment failed"

經過 :

        else
           echo "deployment failed"
        fi

相關內容