+#ifdef CONFIG_CMD_GREPENV
+static int do_env_grep (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+ ENTRY *match;
+ unsigned char matched[env_htab.size / 8];
+ int rcode = 1, arg = 1, idx;
+
+ if (argc < 2)
+ return cmd_usage(cmdtp);
+
+ memset(matched, 0, env_htab.size / 8);
+
+ while (arg <= argc) {
+ idx = 0;
+ while ((idx = hstrstr_r(argv[arg], idx, &match, &env_htab))) {
+ if (!(matched[idx / 8] & (1 << (idx & 7)))) {
+ puts(match->key);
+ puts("=");
+ puts(match->data);
+ puts("\n");
+ }
+ matched[idx / 8] |= 1 << (idx & 7);
+ rcode = 0;
+ }
+ arg++;
+ }
+
+ return rcode;
+}
+#endif
+