[PATCH 8/8] cmd: config: allow simple filtering of output
Simon Glass
sjg at chromium.org
Thu Jul 2 10:30:24 CEST 2026
Hi Rasmus,
On 2026-07-01T17:15:27, Rasmus Villemoes <rv at rasmusvillemoes.dk> wrote:
> cmd: config: allow simple filtering of output
>
> When doing development, it can be quite useful to enable
> CONFIG_CMD_CONFIG, so that one can always check whether a config knob
> one has just enabled has actually made it to target.
>
> Because sometimes, one doesn't flash the right binary, or maybe one
> has just done CONFIG_FOO=y in some config fragment, but that had no
> effect because one would also have to do CONFIG_BAR=y.
>
> However, 2400+ lines of text are rather hard to read through. One
> probably uses a terminal emulator with capturing enabled, but
> searching back through the capture file is a little tedious, and one
> easily ends up finding something that doesn't pertain to the most
> recent 'config' command invocation.
>
> So make it possible to limit the output to those lines containing a
> given string. Like the search functionality in menuconfig, make it
> case insensitive, because it is much more convenient to type "config
> pinctrl" than "config PINCTRL".
> [...]
>
> cmd/config.c | 25 ++++++++++++++++++++++---
> 1 file changed, 22 insertions(+), 3 deletions(-)
> diff --git a/cmd/config.c b/cmd/config.c
> @@ -29,7 +29,23 @@ static int do_config(struct cmd_tbl *cmdtp, int flag, int argc,
> + while (b < e) {
> + n = strchrnul(b, '\n');
> + *n = '\0';
> +
> + if (strcasestr(b, s)) {
> + puts(b);
> + puts('\n');
> + }
> + b = n + 1;
> + }
The two puts() could be a single printf("%s\n", b). Also please add an
explicit #include <linux/string.h> now that we rely on strchrnul() and
strcasestr() here.
Reviewed-by: Simon Glass <sjg at chromium.org>
In addition to Tom's comment, how about a simple sandbox test?
Regards,
Simon
More information about the U-Boot
mailing list