[U-Boot] [PATCH v4] common: add a grepenv command

Peter Tyser ptyser at xes-inc.com
Tue Apr 5 17:00:52 CEST 2011


Hi Kim,

> +#ifdef CONFIG_CMD_GREPENV
> +static int do_env_grep (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
> +{
> +	ENTRY *match;
> +	int matched[env_htab.size];
> +	int rcode = 1, idx;
> +
> +	if (argc < 2) {
> +		cmd_usage(cmdtp);
> +		return 1;
> +	}

This could be:
if (argc < 2)
	return cmd_usage(cmdtp);

> +	for (idx = 0; idx < env_htab.size; idx++)
> +		matched[idx] = 0;

memset()?

<snip>

> +#ifdef CONFIG_CMD_GREPENV
> +U_BOOT_CMD_COMPLETE(
> +	grepenv, CONFIG_SYS_MAXARGS, 0,  do_env_grep,
> +	"search environment variables",
> +	"string ...\n"
> +	"    - list environment name=value pairs matching 'string'",
> +	var_complete
> +);
> +#endif

Support for "env grep" should also be added to the "env" command in
cmd_nvedit.c.  My understanding was that the individual printenv,
setenv, etc commands were deprecated in favor of the unified "env"
command.

Cool feature!

Peter




More information about the U-Boot mailing list