bug in $(wildcard) with trailing slash

View: New views
2 Messages — Rating Filter:   Alert me  

bug in $(wildcard) with trailing slash

by eblake :: Rate this Message:

| View Threaded | Show Only this Message

Make fails to restrict output to just directories when a wildcard
contains both a trailing slash and internal slashes, even though it does
the right thing with no internal slashes.

$ mkdir /tmp/example
$ cd /tmp/example/
$ touch a
$ mkdir b
$ printf 'all:\n\t@echo $(wildcard */)' | make -f -
b/
$ printf 'all:\n\t@echo $(wildcard ./*/)' | make -f -
./b/ ./a

Both invocations should have omitted a, since the trailing slash cannot
match a non-directory (other than a symlink to a directory).

$ make --version | head -n2
GNU Make 3.82
Built for x86_64-redhat-linux-gnu

I encountered this while writing a macro for libvirt; as a workaround, I
ended up using a trailing /. to force just directories, then using
$(patsubst) to strip things back to what I wanted in the first place.

cross_dirs=$(patsubst $(srcdir)/src/%.,%,$(wildcard $(srcdir)/src/*/.))

--
Eric Blake   eblake@...    +1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc (633 bytes) Download Attachment

Re: bug in $(wildcard) with trailing slash

by eblake :: Rate this Message:

| View Threaded | Show Only this Message

On 03/02/2012 06:53 AM, Eric Blake wrote:
> Make fails to restrict output to just directories when a wildcard
> contains both a trailing slash and internal slashes, even though it does
> the right thing with no internal slashes.

Sorry about that; I meant bug-make, but my mailer autocompleted to the
wrong list.

--
Eric Blake   eblake@...    +1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc (633 bytes) Download Attachment