2 Mar 2012 14:53
bug in $(wildcard) with trailing slash
Eric Blake <eblake <at> redhat.com>
2012-03-02 13:53:07 GMT
2012-03-02 13:53:07 GMT
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 <at> echo $(wildcard */)' | make -f - b/ $ printf 'all:\n\t <at> 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 <at> redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org(Continue reading)
RSS Feed