[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug #64339] $(filter) and $(filter-out) interpret "match" in surprising
From: |
Eli Zaretskii |
Subject: |
[bug #64339] $(filter) and $(filter-out) interpret "match" in surprising ways |
Date: |
Thu, 22 Jun 2023 15:07:15 -0400 (EDT) |
URL:
<https://savannah.gnu.org/bugs/?64339>
Summary: $(filter) and $(filter-out) interpret "match" in
surprising ways
Group: make
Submitter: eliz
Submitted: Thu 22 Jun 2023 10:07:13 PM IDT
Severity: 3 - Normal
Item Group: None
Status: None
Privacy: Public
Assigned to: None
Open/Closed: Open
Discussion Lock: Any
Component Version: SCM
Operating System: Any
Fixed Release: None
Triage Status: None
_______________________________________________________
Follow-up Comments:
-------------------------------------------------------
Date: Thu 22 Jun 2023 10:07:13 PM IDT By: Eli Zaretskii <eliz>
The GNU Make Manual says:
'$(filter-out PATTERN...,TEXT)'
Returns all whitespace-separated words in TEXT that _do not_ match
any of the PATTERN words, removing the words that _do_ match one or
more. This is the exact opposite of the 'filter' function.
For example, given:
objects=main1.o foo.o main2.o bar.o
mains=main1.o main2.o
the following generates a list which contains all the object files
not in 'mains':
$(filter-out $(mains),$(objects))
Note that the text doesn't really say what it means to "match" in this
context, nor what exactly is PATTERN. The example might make you believe the
"match" means "substring". That is A "matches" B if A is some substring of B.
But this is not the case. Observe:
$ make -f-
ORIG=foo123 bar-xyz baz-yes
EXCLUDE=bar foo
all:
@echo "$(filter-out $(EXCLUDE),$(ORIG))"
^D
=> foo123 bar-xyz baz-yes
That is, "foo123" does NOT match "foo", and "bar-xyz" does NOT match "bar".
The following does work, though:
$ make -f-
ORIG=./foo ./bar ./baz
EXCLUDE=%bar %foo
all:
@echo "$(filter-out $(EXCLUDE),$(ORIG))"
^D
=> ./baz
So now we perhaps understand that PATTERN is something that includes the %
wildcard somewhere. This should be explained in the manual, and the manual
should also somehow justify the special case of exact string equality, in
which case the % wildcard is not required.
IOW, having the exact string equality as the only example in this case is
misleading and confusing. I learned this the hard way, having just spent an
hour debugging my Makefile where $(filter-out) didn't do its job, because I
thought "./foo" should match "foo", based on what the manual says.
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?64339>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
- [bug #64339] $(filter) and $(filter-out) interpret "match" in surprising ways,
Eli Zaretskii <=