以下代碼產生錯誤「整數表達式預期」:如果或病症產生「整數表達預期」
for SOURCE_PATH in work/sources/*; do
git diff --exit-code &>/dev/null || SOMETHING_TO_COMMIT=$?
if [ "$SOMETHING_TO_COMMIT" -eq "0" ] || [ "$SOMETHING_TO_COMMIT" -eq "" ] ; then
echo "NOTHING TO COMMIT FOR $SOURCE_PATH";
else
echo "COMMIT FOR $SOURCE_PATH"
git -C "$DIR/$SOURCE_PATH" commit -F ${COMMIT_MESSAGE_FILE}
fi
done
錯誤是上線if [ "$SOMETHING_TO_COMMIT" -eq "0" ] || [ "$SOMETHING_TO_COMMIT" -eq "" ] ; then
。看來[ "$SOMETHING_TO_COMMIT" -eq "0" ]
或[ "$SOMETHING_TO_COMMIT" -eq "" ]
應該會產生整數。
如何解決這個問題?
我接受了@netizen答案,因爲它是直接回答我的問題,但我給予好評你的! – bux