summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRasmus Villemoes <ravi@prevas.dk>2024-10-30 22:34:02 +0100
committerTom Rini <trini@konsulko.com>2024-11-15 16:36:18 -0600
commit4d28fcdf65950576f0e0f5447c89421126dc4943 (patch)
tree9c710b4c65110058012846c4eabdea4344c0ea7e
parent84b95e918942d0e29e3634d265694030f76faf5a (diff)
cmd/nvedit.c: teach 'env default' to optionally keep runtime variables
It can be useful to set all variables defined in the default environment to the value they have there, but without removing variables that are only defined at runtime. This can sort-of be done today, by using the "env default var1 var2 ..." variant, but that requires listing all variables defined in the default environment. It's much more convenient to be able to say env default -k -a The -k flag is also meaningful in the other case: If var1 is not defined in the default environment, but var2 is, env default var1 var2 would emit a warning about var1 not being in the default env and thus being deleted. With -k, there's no warning, and var1 is kept as-is. Signed-off-by: Rasmus Villemoes <ravi@prevas.dk>
-rw-r--r--cmd/nvedit.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/cmd/nvedit.c b/cmd/nvedit.c
index 392f90f8698..1f259801293 100644
--- a/cmd/nvedit.c
+++ b/cmd/nvedit.c
@@ -523,6 +523,9 @@ static int do_env_default(struct cmd_tbl *cmdtp, int flag,
case 'f': /* force */
env_flag |= H_FORCE;
break;
+ case 'k':
+ env_flag |= H_NOCLEAR;
+ break;
default:
return cmd_usage(cmdtp);
}
@@ -1133,8 +1136,9 @@ U_BOOT_LONGHELP(env,
#if defined(CONFIG_CMD_ENV_CALLBACK)
"callbacks - print callbacks and their associated variables\nenv "
#endif
- "default [-f] -a - [forcibly] reset default environment\n"
- "env default [-f] var [...] - [forcibly] reset variable(s) to their default values\n"
+ "default [-k] [-f] -a - [forcibly] reset default environment\n"
+ "env default [-k] [-f] var [...] - [forcibly] reset variable(s) to their default values\n"
+ " \"-k\": keep variables not defined in default environment\n"
"env delete [-f] var [...] - [forcibly] delete variable(s)\n"
#if defined(CONFIG_CMD_EDITENV)
"env edit name - edit environment variable\n"