tech-userlevel archive

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

Re: make: Unfinished character list in pattern



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



Home | Main Index | Thread Index | Old Index