Thread View: muc.lists.netbsd.tech.userlevel
8 messages
8 total messages
Started by Edgar Fuß
Tue, 13 Oct 2026 15:04
make: Unfinished character list in pattern
Author: Edgar Fuß
Date: Tue, 13 Oct 2026 15:04
Date: Tue, 13 Oct 2026 15:04
17 lines
1463 bytes
1463 bytes
make(1) from -11 chokes on character lists in globs ending with a hyphen:
foo= foo bar foo-bar
default:
echo ${foo:M*[+-]*}
However, glob(7) says
In order to represent itself, a `-' must either be quoted
or the first or last character in the character list.
and this works as expected with make(1) from -10.
--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-admin@muc.de
Re: make: Unfinished character list in pattern
Author: Edgar Fuß
Date: Tue, 13 Oct 2026 15:07
Date: Tue, 13 Oct 2026 15:07
7 lines
1402 bytes
1402 bytes
> make(1) from -11 chokes on character lists in globs ending with a hyphen: It even chokes if I esacpe the hyphen. It only works at the beginning of the list. -- Posted automagically by a mail2news gateway at muc.de e.V. Please direct questions, flames, donations, etc. to news-admin@muc.de
Re: make: Unfinished character list in pattern
Author: Roland Illig
Date: Sat, 31 Oct 2026 21:56
Date: Sat, 31 Oct 2026 21:56
34 lines
10697 bytes
10697 bytes
Am 13.10.2026 um 17:04 schrieb Edgar Fuß:
> make(1) from -11 chokes on character lists in globs ending with a hyphen:
>
> foo= foo bar foo-bar
>
> default:
> echo ${foo:M*[+-]*}
>
> However, glob(7) says
>
> In order to represent itself, a `-' must either be quoted
> or the first or last character in the character list.
>
> and this works as expected with make(1) from -10.
That was a deliberate change in order to catch cases where the end of a
range was accidentally omitted.
The wording in make's manual page doesn't refer to glob(7), it doesn't
even suggest what the semantics of the "standard shell wildcard
characters" might be. And in fact, make(1)'s :M modifier differs from
glob(7) in many more edge cases.
You can write :M*[-+]* instead.
$ make -v '${:U a +b ,c -d :M*[-+]*}'
Roland
--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-admin@muc.de
Re: make: Unfinished character list in pattern
Author: Robert Elz
Date: Sat, 31 Oct 2026 23:28
Date: Sat, 31 Oct 2026 23:28
50 lines
3088 bytes
3088 bytes
Date: Sat, 31 Oct 2026 22:56:41 +0100
From: Roland Illig <roland.illig@gmx.de>
Message-ID: <23522fbb-d445-457c-bb54-2ea782037404@gmx.de>
| That was a deliberate change in order to catch cases where the end of a
| range was accidentally omitted.
How about cases where the beginning of the range is accidentally omitted?
That explanation is really a fairly poor justification.
| You can write :M*[-+]* instead.
That works in most cases, but how about when you want to match any
of a ']' a '-' or a '_'.
If you put the '-' first, then wherever you put the ']' it ends things
rather than being a character in the set of possibles. If you put the
']' first (after the optional invert/negate character, assuming make has
one of those - ie: any char except...), which is the one place it cannot
end the set, as if it did, the set would be empty, which makes no sense
at all (for this purpose) then either you write
[]-_]
in which case you get the range from ] to _ (which includes ^, which is
not intended to be there, but doesn't include '-' which is), or you
write
[]_-]
which is the way that glob(7) intends it to be done, and the way it is
done in everything else that has glob style patterns, but which make
apparently rejects now.
I'd suggest reverting whatever change it was that made it an error to
put a '-' last - there are reasons that glob (since 6th edition days,
when glob was a separate program, not built into the Thompson shell,
though it did know when it should run glob) was designed the way it
was, inventing new/different syntaxes, for essentially the same purpose,
is just not the right thing to do. If old sytle glob isn't what you
want, then the next step is to use RE's instead.
kre
--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-admin@muc.de
Re: make: Unfinished character list in pattern
Author: Edgar Fuß
Date: Sun, 01 Nov 2026 11:19
Date: Sun, 01 Nov 2026 11:19
26 lines
2659 bytes
2659 bytes
> That was a deliberate change Which broke my real-world application. Fortunately, on a development system. > in order to catch cases where the end of a range was accidentally omitted. 1. this is UNIX. 2. how do you catch cases where the beginning of a range was accidentally omitted? > The wording in make's manual page doesn't refer to glob(7), it doesn't > even suggest what the semantics of the "standard shell wildcard > characters" might be. I would suppose that, if you ask a hundred UNIX programmers what "standard shell wildcard characters" mean, ninty-nine and a half of them would refer to "glob" in their answer. > And in fact, make(1)'s :M modifier differs from glob(7) in many more > edge cases. Then, in my humble opinion, these differences should be fixed or at least documented. Or even better, eliminated for good by using glob(3). > You can write :M*[-+]* instead. Unless I also want to match ] or !. -- Posted automagically by a mail2news gateway at muc.de e.V. Please direct questions, flames, donations, etc. to news-admin@muc.de
Re: make: Unfinished character list in pattern
Author: Roland Illig
Date: Sun, 01 Nov 2026 12:38
Date: Sun, 01 Nov 2026 12:38
40 lines
10842 bytes
10842 bytes
Am 13.10.2026 um 17:04 schrieb Edgar Fuß:
> make(1) from -11 chokes on character lists in globs ending with a hyphen:
>
> foo= foo bar foo-bar
>
> default:
> echo ${foo:M*[+-]*}
>
> However, glob(7) says
>
> In order to represent itself, a `-' must either be quoted
> or the first or last character in the character list.
>
> and this works as expected with make(1) from -10.
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.
After make(1) has determined that the character range matches, it scans
for the closing ']' of the character list, but it surprisingly starts
from the beginning of the character range. This time, the ']' is not an
ordinary character anymore but instead finishes the character list.
These two completely different interpretations of ']' make it
error-prone. Therefore, even though "it is UNIX", I'd want make(1) to
reject patterns that behave unexpectedly, and this pattern is one of them.
The pattern that does what you expect is "*[+-+-]*".
Roland
--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-admin@muc.de
Re: make: Unfinished character list in pattern
Author: Robert Elz
Date: Sun, 01 Nov 2026 16:22
Date: Sun, 01 Nov 2026 16:22
75 lines
4226 bytes
4226 bytes
Date: Sun, 1 Nov 2026 13:38:46 +0100
From: Roland Illig <roland.illig@gmx.de>
Message-ID: <16ce95cc-154d-41e6-96ca-12644cbfb9d6@gmx.de>
| 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
--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-admin@muc.de
Re: make: Unfinished character list in pattern
Author: David Holland
Date: Sun, 01 Nov 2026 17:40
Date: Sun, 01 Nov 2026 17:40
26 lines
2970 bytes
2970 bytes
On Sun, Nov 01, 2026 at 01:38:46PM +0100, Roland Illig wrote: > 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. > > After make(1) has determined that the character range matches, it scans > for the closing ']' of the character list, but it surprisingly starts > from the beginning of the character range. This time, the ']' is not an > ordinary character anymore but instead finishes the character list. ...so that's a bug, and the obvious fix is to make it scan correctly. There are and have been plenty of other cases where make rescans strings and doesn't do it quite the same each time, and it just shouldn't do that. (It doesn't matter if it's been wrong for 35 years; that doesn't grant any virtue to the wrong behavior.) -- David A. Holland dholland@netbsd.org -- Posted automagically by a mail2news gateway at muc.de e.V. Please direct questions, flames, donations, etc. to news-admin@muc.de
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads