我喜歡檢查多個變數串列中是否至少有一個變數不為空。
例如,我喜歡將以下作業條件合并為一個陳述句:
ifneq (${VAR1},)
...command true for all ...
else ifneq (${V2},)
... same command as above...
else ifneq (${VAR3},)
... same command as first...
else ifneq (${V4},)
... same command as first...
else
...other command....
endif
我喜歡有一個 MAKE(不是 shell)條件,比如
ifneq (${VAR1},) || (${V2},) || (${VAR3},) || (${VAR3},)
...command true for all ...
else
...other command....
endif
uj5u.com熱心網友回復:
ifneq ($(VAR1)$(VAR2)$(VAR3),)
uj5u.com熱心網友回復:
類似于@HolyBlackCat 的回答:
ifneq ($(or $(VAR1),$(VAR2),$(VAR3)),)
兩者都會做同樣的事情,@HolyBlackCat 的回答更短,但如果你想做一些稍微復雜的事情,那么這種方法很高興知道。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/343430.html
