小编Ser*_*zov的帖子

如果输出是通过管道传输的,为什么 make 会忽略转义序列

在 Makefile 中,我想打印一个以十六进制数字表示的字节并将其传递给另一个程序的 STDIN。由于某种原因,它不起作用:

without-pipe:
    @printf '\x66\x6f\x6f'

with-bash-and-pipe:
    @/bin/bash -c "printf '\x66\x6f\x6f' | cat"

with-pipe:
    @printf '\x66\x6f\x6f' | cat
Run Code Online (Sandbox Code Playgroud)

运行该文件会产生:

$ make without-pipe 
foo

$ make with-bash-and-pipe 
foo

$ make with-pipe 
\x66\x6f\x6f
Run Code Online (Sandbox Code Playgroud)

我缺少什么功能make以及使最后一个目标产生相同输出的正确方法是什么。这with-bash-and-pipe是一种解决方法。

pipe make escape-characters binary-files

5
推荐指数
1
解决办法
391
查看次数

标签 统计

binary-files ×1

escape-characters ×1

make ×1

pipe ×1