【发布时间】:2021-05-28 13:22:12
【问题描述】:
我写了一个 Makefile 的 sn-p,它在执行 rm 之前检查文件是否存在。
clean:
echo "Attempt to remove $(exec) file"
if test -f "${exec}" ; then \
echo "Removing file ${exec}" ; \
rm ${exec} ; \
else \
echo "No ${exec} file to remove" ; \
fi
if "$(wildcard *.o)" = "" ; then \
echo "No files found" ; \
else \
echo " Found $(wildcard *.o) " ; \
fi
第一个 if 语句运行良好
尝试删除 hello 文件
没有要删除的 hello 文件
而第二个产生这个:
/bin/sh: 1: main.o factorial.o: 未找到
找到 main.o factorial.o
我的问题是:为什么 make recipe 会产生有效的输出(这些文件确实存在)而 shell 却没有?为什么 shell 甚至试图找到它们?
感谢您抽出宝贵时间阅读此问题。这是我第一次来这里,所以如果我做了不恰当的事情,请告诉我
【问题讨论】: