[PATCH] Makefile: avoid non-standard sed expressions

Quentin Schulz quentin.schulz at cherry.de
Thu Nov 28 12:41:16 CET 2024


Hi Mark,

On 11/28/24 12:25 PM, Mark Kettenis wrote:
>> Date: Wed, 27 Nov 2024 13:42:50 +0100
>> From: Quentin Schulz <quentin.schulz at cherry.de>
> 
> Hi Quentin,
> 
>> Hi Mark,
>>
>> On 11/26/24 8:12 PM, Mark Kettenis wrote:
>>> The '?' that is used in the sed expression that determines MK_ARCH
>>> is part of the extended regular expression syntax, but the default
>>> behaviour of sed as specified by POSIX is to use only basic regular
>>> expression syntax.  Use the equivalent '\{0,1\}' instead as
>>> suggested by the OpenBSD re_format(7) man page.
>>>
>>> Fixes: 04b1d84221d5 ("Makefile: fix empty MK_ARCH when using ccache")
>>
>> Tested-by: Quentin Schulz <quentin.schulz at cherry.de>
>>
>> Considering that it's not the first time someone breaks this by making
>> it non-POSIX, can you add a comment just above with a link to the
>> re_format(7) man page so people are at least more aware than they are
>> right now?
> 
> It is unfortunate that GNU sed has these extensions that are enabled
> by default.  Just mentioning the OpenBSD man page is probably not
> going to help, but I guess I could put in a link to
> 
>    https://man.openbsd.org/re_format
> 
> with a comment that only BREs should be used.
> 

What about adding --posix to the sed command. GNU sed has it, would that 
work with OpenBSD and is it enough? At least with GNU sed, ? doesn't 
work with --posix, and I had to replace it with {0,1} to make it work.

BREs don't seem to be entirely supported according to the manpage for 
GNU sed, c.f. 
https://www.man7.org/linux/man-pages/man1/sed.1.html#REGULAR_EXPRESSIONS 
so not sure it's a better than no hint :/

Cheers,
Quentin


More information about the U-Boot mailing list