我想让我的Makefile在输出文本时去掉行尾的换行符,但是无法做到。在OS X上出现了这种情况(在Linux上一切正常)。
Makefile
a:
@echo -n "hello"
b:
@echo -n hello
c:
@/bin/echo -n "hello"
输出:
$make a
-n hello
$make b
hello$make c
hello$
换句话说,make a
出了问题。到底发生了什么?是make使用了内置的echo命令吗?显然,双引号的存在改变了行为,但是为什么?
更新
正如@chepner发现的那样,在makefile中使用完整路径/bin/echo
可以正确理解-n标志。