if-statement - 我也可以在 elif 中使用 make 条件吗?
问题描述
我可以使用make 的条件进行简单的检查,如下所示:
var = yes
ifeq $(var) "yes"; then
echo "yes"
else
echo "no"
fi
但是文档对elif
. 我可以这样做吗?
var = yes
ifeq $(var) "yes"; then
echo "yes"
elifeq $(var) "no"; then
echo "no"
else
echo "invalid"
fi
如果没有,那有可能吗,还是我必须制作嵌套条件或使用test
?
解决方案
我可以这样做吗?
不,您不能使用elifeq
.
我必须制作嵌套条件还是使用 test ?
不,文档说:
复杂条件的语法如下: ... 或:
conditional-directive-one text-if-one-is-true else conditional-directive-two text-if-two-is-true else text-if-one-and-two-are-false endif
必要时可以有尽可能多的“其他条件指令”子句。
注意这里它说else conditional-directive-two。所以,你可以写:
var = yes
ifeq ($(var),yes)
$(info "yes")
else ifeq ($(var),no)
$(info "no")
else
$(info "invalid")
endif
请注意,您的原始语法不是有效的 makefile 语法。看起来您正在尝试使用 shell 语法:makefile 不是 shell 脚本,并且不使用相同的语法。
推荐阅读
- ios - 将 IBOutlet 按钮放入数组时发出警告
- tablesorter - 从简单表中删除行
- javascript - 如何使用 Javascript 访问 CSS Grid 属性
- python - python中的语法错误,同时获取数据到power bi
- asp.net - 代理 aspx 页面
- python - 在美丽的汤中找到下一个 div 标签
- firebase - 为什么有时 imageUrl 会保存在云 Firestore 数据库中,而有时却没有保存
- c - 我试图找出一种将月份名称转换为整数的方法
- python - 在 Python 中,如何找出哪个模块导入了特定模块
- php - 处理对象数组