tech-userlevel archive

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

Re: make: Unfinished character list in pattern



    Date:        Sun, 1 Nov 2026 13:38:46 +0100
    From:        Roland Illig <roland.illig%gmx.de@localhost>
    Message-ID:  <16ce95cc-154d-41e6-96ca-12644cbfb9d6%gmx.de@localhost>

  | Depending on what you expect. Since 1993, your particular pattern has
  | also matched the words "UPPER", "Mixed" and "mixeD", but not "lower".

  | That's because when make(1) parses a character range such as '+-]', it
  | treats ']' as an ordinary character. The range is thus from '+' to ']',
  | which includes all uppercase letters.

Clearly a bug that needed to be fixed, the question is what the fix
should be.  Making the sequence '-]' into an error, rather than
meaning '-' is one of the characters in the set, and ']' ends it,
is almost certainly not the correct approach.

  | These two completely different interpretations of ']' make it
  | error-prone.

Definitely, simply wrong, and needs (or needed) fixing.

  | Therefore, even though "it is UNIX", I'd want make(1) to
  | reject patterns that behave unexpectedly, and this pattern is one of them.

You mean "behaved unexpectedly" - and "reject" is not the only solution.
That is, instead of making patterns which were broken previously be
rejected, just make them behave as they're expected to behave, so they
are no longer behaving unexpectedly.

Can you point to a single real world example where anything is assuming
that the way you have described make as having been working (and I fully
expect that you know what you're talking about there, and it did work
like that) is the intended operation of some Makefile ?

If there are none, then surely anyone who write "-]" to end a set of
chars to match, was intending to include a literal '-' in the set, and
that is what make should be causing to happen.

  | The pattern that does what you expect is "*[+-+-]*".

That's fine for that pattern, but it need not be that complex, and
users should not need to do this kind of bizarre manipulation (writing
individual characters as ranges from themselves to themselves) in order
to achieve what ought to be trivial.

I assume that "*[+-+---]*" would work as well?   But why?  "*[+-]*"
or "*[-+]*" should both work, as in both cases there are just 2 chars
between the brackets, a range requires three, hence there is no range.

That old make had a bug where it would treat the ']' as the end of a
range if preceded by a '-' which could be a range '-' instead of only
a literal one, is irrelevant, just fix that bug, so it no longer happens,
and there should be no further issues.   Make "make" behave like every
other unix utility which uses glob style patterns.  If writing the code
for that is hard, there's always fnmatch(3) which will do it for you.
(It is a POSIX standard function, so should exist, and work the same,
everywhere.)

kre



Home | Main Index | Thread Index | Old Index