[PATCH 3/4] MAKEALL: error out on options placed after the defconfig argument
Ahmad Fatoum
a.fatoum at barebox.org
Mon Feb 23 04:06:43 PST 2026
On 2/23/26 1:05 PM, Sascha Hauer wrote:
> On Mon, Feb 23, 2026 at 12:52:52PM +0100, Ahmad Fatoum wrote:
>> Hi,
>>
>> On 2/23/26 12:50 PM, Sascha Hauer wrote:
>>> On Mon, Feb 23, 2026 at 12:31:34PM +0100, Ahmad Fatoum wrote:
>>>> getopts stops parsing at the first non-option argument, so options
>>>> like -k after the defconfig name silently end up as positional
>>>> arguments. For bare defconfigs these get misinterpreted as pytest
>>>> options and are silently ignored, leading to a build without the
>>>> intended configuration.
>>>>
>>>> Detect this by checking for trailing arguments when any positional
>>>> argument is a bare defconfig (not a labgrid .yaml config, where
>>>> extra arguments are intentionally forwarded to pytest).
>>>
>>> Can't we use getopt for MAKEALL instead of getopts? getopt just does the
>>> right thing.
>>
>> When using MAKEALL with a labgrid yaml instead of a defconfig, it
>> derives the defconfig name and interprets the options after the yaml as
>> pytest options, so use of getopt would break that.
>
> You can use -- as final argument which stops getopt parsing.
Fair enough, I think 1,2,4 are good to go though?
I will rework 3/4 later.
Thanks,
Ahmad
>
> Sascha
>
>>
>> Cheers,
>> Ahmad
>>
>>>
>>> Sascha
>>>
>>>>
>>>> Co-Authored-By: Claude Opus 4.6 <noreply at anthropic.com>
>>>> Signed-off-by: Ahmad Fatoum <a.fatoum at barebox.org>
>>>> ---
>>>> MAKEALL | 9 +++++++++
>>>> 1 file changed, 9 insertions(+)
>>>>
>>>> diff --git a/MAKEALL b/MAKEALL
>>>> index c36aed625820..dd0b7f8003cc 100755
>>>> --- a/MAKEALL
>>>> +++ b/MAKEALL
>>>> @@ -440,6 +440,15 @@ else
>>>>
>>>> configs+=($i)
>>>> done
>>>> + if [ ${#pytest_opts[@]} -gt 0 ]; then
>>>> + for i in "${configs[@]}"; do
>>>> + if ! [[ $i =~ .yaml$ ]]; then
>>>> + echo "error: unexpected arguments after defconfig: ${pytest_opts[*]}" >&2
>>>> + echo "hint: place all options before the defconfig argument" >&2
>>>> + exit 1
>>>> + fi
>>>> + done
>>>> + fi
>>>> for i in "${configs[@]}"; do
>>>> config=$i
>>>> if [[ $i =~ ^.*/([^/]+)/([^@]*@|)([^.]+).yaml$ ]]; then
>>>> --
>>>> 2.47.3
>>>>
>>>>
>>>>
>>>
>>
>>
>
More information about the barebox
mailing list