Bash 管道在makefile中不工作

Bash 管道在makefile中不工作,bash,makefile,grep,Bash,Makefile,Grep,我只说出了重要的几句话: SHELL := /bin/bash leaks: build_eagle_test grep EagleMemory_Allocate -r eagle | perl -nle 'm/"(.*)"/; print $1' | sort | uniq > leaks.alloc.tmp grep "EagleMemory_Mock(" -r eagle_test | perl -nle 'm/"(.*)"/; print $1' | sort |

我只说出了重要的几句话:

SHELL := /bin/bash

leaks: build_eagle_test
    grep EagleMemory_Allocate -r eagle | perl -nle 'm/"(.*)"/; print $1' | sort | uniq > leaks.alloc.tmp
    grep "EagleMemory_Mock(" -r eagle_test | perl -nle 'm/"(.*)"/; print $1' | sort | uniq > leaks.alloc_test.tmp

当我在bash中运行这些行时,没有问题。但是从make文件,它只将
grep
导入out文件(实际上忽略了中间的阶段…

需要将
$
引用为
$
,例如

SHELL:=/bin/bash
泄漏:
grep EagleMemory_Allocate-r eagle | perl-nle'm/“(.*)”/;打印$$1'| sort | uniq>leaks.alloc.tmp
grep“EagleMemory|u Mock(“-r eagle|u test | perl-nle'm/”(.*)”/;print$$1'| sort | uniq>leaks.alloc|u test.tmp
问题是Make对bash语法一无所知,并且忽略了命令行上的所有
'“
引用。它将
$1
解释为Make上下文中变量
1
的值,但没有这样的变量,因此变为空白

您可以在Make的输出中看到这一点,当它回显从原始Makefile运行的命令时:

$make
grep EagleMemory|u Allocate-r eagle | perl-nle'm/“(.*)”/;print'| sort | uniq>leaks.alloc.tmp
grep“EagleMemory|u Mock(“-r eagle|u test | perl-nle'm/”(.*)”/;print'| sort | uniq>leaks.alloc|u test.tmp
请注意,
$1
已消失