From mboxrd@z Thu Jan 1 00:00:00 1970 From: Peter Tyser Date: Tue, 05 Apr 2011 10:00:52 -0500 Subject: [U-Boot] [PATCH v4] common: add a grepenv command In-Reply-To: <20110404201829.82dbf9c7.kim.phillips@freescale.com> References: <20110401174658.eaa8d773.kim.phillips@freescale.com> <20110404144518.41716465.kim.phillips@freescale.com> <20110404205706.688E8151F83@gemini.denx.de> <20110404201829.82dbf9c7.kim.phillips@freescale.com> Message-ID: <1302015652.24947.27338.camel@petert> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de 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()? > +#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