我想在makefile中的if條件中進行最簡單的比較。 我正在使用cygwin。我不斷收到錯誤XX was unexpected at this time
。其中XX
是比較運算符的LHS。這個確切的makefile運行在mks上,但現在我必須使用cygwin,因爲我現在正在64位窗口上運行它。測試如果條件makefile上的cygwin
這裏是我的代碼:
DEBUG=0
all:
if test $(DEBUG) != 0 then\
echo "not equal to 0"\
fi
我也試過這樣:
DEBUG=0
all:
if [ $(DEBUG) != 0 ] then\
echo "not equal to 0"\
fi
這:
DEBUG=0
all:
if [ "$(DEBUG)" != "0" ] then\
echo "not equal to 0"\
fi
這是錯誤:
0 was unexpected at this time. *** [all] Error 255
============================================== ====== 更新:
我已經嘗試添加缺少的;
,並使它作爲@Jonas的單線程。建議但仍然有同樣的問題。
一個內膽:
if [ $(DEBUG) != 0 ] ; then echo "not equal to 0" ; fi
用分號:
if [ $(DEBUG) != 0 ] ; then \
echo "not equal to 0" ; \
fi
是的,我使用的標籤沒有空格。而且我只將行結尾更改爲LF
。
Shell語句在結尾處需要';'。 –
@πάνταῥεῖ它沒有工作 –
你可能想解釋你想要做什麼,而不是你的嘗試解決方案。參見[XY問題](http://meta.stackexchange.com/questions/66377/what-is-the-xy-problem)。 – user657267