`makefile` 中 `rm` 命令的规则文件匹配是什么?

huangapple go评论56阅读模式
英文:

what is the rule file matching of command `rm` in makefile?

问题

I was required to run a makefile on mint, I input the option 'clean' about:

clean:
rm -f test_{a,b}.o

I type this order in shells rm -f test_{a,b}.o, and it do delete the file test_a.o and test_b.o, but it doesn't work on Mint OS, but it work on CentOS7.

I want to find the reason for this problem. now I use rm -f test_a.o test_b.o instead temporarily.

英文:

I was required to run a makefile on mint, I input the option 'clean' about:

clean:
<tab> rm -f test_{a,b}.o

I type this order in shells rm -f test_{a,b}.o, and it do delete the file test_a.o and test_b.o, but it doesn't work on Mint OS, but it work on CentOS7.

I want to find the reason for this problem. now I use rm -f test_a.o test_b.o instead temporarily.

答案1

得分: 1

这取决于shell:大括号扩展在Bash中受支持,但例如在dash中不受支持,dash是Ubuntu上的默认/bin/sh shell;而/bin/sh是Makefile中的默认shell。您可以通过以下方式在Makefile 中切换所使用的shell:

SHELL = /bin/bash
英文:

This depends on the shell: brace expansion is supported by Bash, but for example not by dash, which is the default /bin/sh shell on Ubuntu; and /bin/sh is the default shell in Makefiles. You could switch the shell used in the Makefile with

SHELL = /bin/bash

huangapple
  • 本文由 发表于 2023年3月1日 12:14:29
  • 转载请务必保留本文链接:https://go.coder-hub.com/75599511.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定