summaryrefslogtreecommitdiff
path: root/common/cmd_nvedit.c
diff options
context:
space:
mode:
authorJoe Hershberger <joe.hershberger@ni.com>2012-12-11 22:16:36 -0600
committerTom Rini <trini@ti.com>2012-12-13 11:46:57 -0700
commit9d8d661d7fda6ccda1d5fc31565f207b7648bc6d (patch)
treec9c47df3ca209fe5d9a12903ad372157cff38d72 /common/cmd_nvedit.c
parent24ab5a1914283b891fa50bc285128bc5fd4ac50a (diff)
downloadu-boot-imx-9d8d661d7fda6ccda1d5fc31565f207b7648bc6d.zip
u-boot-imx-9d8d661d7fda6ccda1d5fc31565f207b7648bc6d.tar.gz
u-boot-imx-9d8d661d7fda6ccda1d5fc31565f207b7648bc6d.tar.bz2
env: Implement the env delete command
Implement a way to delete more than one variable at a time. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Diffstat (limited to 'common/cmd_nvedit.c')
-rw-r--r--common/cmd_nvedit.c35
1 files changed, 32 insertions, 3 deletions
diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c
index 988d6b3..7633f0c 100644
--- a/common/cmd_nvedit.c
+++ b/common/cmd_nvedit.c
@@ -725,8 +725,36 @@ static int do_env_default(cmd_tbl_t *cmdtp, int __flag,
static int do_env_delete(cmd_tbl_t *cmdtp, int flag,
int argc, char * const argv[])
{
- printf("Not implemented yet\n");
- return 0;
+ int env_flag = H_INTERACTIVE;
+ int ret = 0;
+
+ debug("Initial value for argc=%d\n", argc);
+ while (argc > 1 && **(argv + 1) == '-') {
+ char *arg = *++argv;
+
+ --argc;
+ while (*++arg) {
+ switch (*arg) {
+ case 'f': /* force */
+ env_flag |= H_FORCE;
+ break;
+ default:
+ return CMD_RET_USAGE;
+ }
+ }
+ }
+ debug("Final value for argc=%d\n", argc);
+
+ env_id++;
+
+ while (--argc > 0) {
+ char *name = *++argv;
+
+ if (!hdelete_r(name, &env_htab, env_flag))
+ ret = 1;
+ }
+
+ return ret;
}
#ifdef CONFIG_CMD_EXPORTENV
@@ -995,7 +1023,7 @@ static cmd_tbl_t cmd_env_sub[] = {
U_BOOT_CMD_MKENT(ask, CONFIG_SYS_MAXARGS, 1, do_env_ask, "", ""),
#endif
U_BOOT_CMD_MKENT(default, 1, 0, do_env_default, "", ""),
- U_BOOT_CMD_MKENT(delete, 2, 0, do_env_delete, "", ""),
+ U_BOOT_CMD_MKENT(delete, CONFIG_SYS_MAXARGS, 0, do_env_delete, "", ""),
#if defined(CONFIG_CMD_EDITENV)
U_BOOT_CMD_MKENT(edit, 2, 0, do_env_edit, "", ""),
#endif
@@ -1060,6 +1088,7 @@ static char env_help_text[] =
#endif
"default [-f] -a - [forcibly] reset default environment\n"
"env default [-f] var [...] - [forcibly] reset variable(s) to their default values\n"
+ "env delete [-f] var [...] - [forcibly] delete variable(s)\n"
#if defined(CONFIG_CMD_EDITENV)
"env edit name - edit environment variable\n"
#endif