bug-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug #52076] wildcard/glob should be sorted


From: anonymous
Subject: [bug #52076] wildcard/glob should be sorted
Date: Wed, 11 Oct 2017 15:35:30 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0

Follow-up Comment #13, bug #52076 (project make):

There are two use-cases I know of where reintroducing sorting might cause
problems and need reworking of existing makefiles.

The first is where precedence is wanted. For example:

$(firstword $(wildcard dir1/file dir2/file dir3/file))

Here, file may not exist in all directories and the aim is to find the first
instance of file, first looking in dir1, and then dir2, and then dir3 - like a
series of -I options on a compiler. With sorting this might need to be changed
to:

$(firstword $(wildcard dir1/file) $(wildcard dir2/file) $(wildcard
dir3/file))

The second is trying to detect whether all files in a list exist. Currently
this can be achieved with:

$(if $(findstring $(files),$(wildcard $(files))),exist,something_missing)

With sorting of wildcard, a sort would also need to be added as follows:

$(if $(findstring $(sort $(files)),$(wildcard
$(files))),exist,something_missing)

So this ends up adding two useless sort operations. This second use-case is
typically used with sentinel type rules that generate more than one target.
Here the aim is to detect if any of the targets are missing and if so then
force the sentinel rule to rebuild them.

Neither of these may be a compelling reason to reason to keep things unsorted,
and none of them actually use globbing - instead filenames are explicit.

It depends exactly what adding sorting means. Does it mean sorting the result
of each individual globbing result in the wildcard separately, or is it
sorting the whole result of wildcard.

Given a directory containing:

z1 y1 y2 x1

would $(wildcard **1 **2) return:

x1 y1 z1 y2

or

x1 y1 y2 z1

testing with echo **1 **2 on linux I get the first result, and this result
would not break the use-cases. 

Anyway, just wanted to point out there are existing makefiles that could be
affected if sorting were reintroduced.


    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?52076>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]