
Hi Gerlando,
On Wed, Dec 7, 2011 at 5:30 AM, Gerlando Falauto gerlando.falauto@keymile.com wrote:
Changes in the syntax (user API) for "env default": -f: override write-once variables -a: all (resetting the whole env is NOT the default behavior)
Signed-off-by: Gerlando Falauto gerlando.falauto@keymile.com
Tested-by: Simon Glass sjg@chromium.org
README | 2 ++ common/cmd_nvedit.c | 43 ++++++++++++++++++++++++++++++++++++------- common/env_common.c | 31 ++++++++++++++++++++++++++++++- include/config_cmd_all.h | 1 + include/environment.h | 5 +++++ 5 files changed, 74 insertions(+), 8 deletions(-)
diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c index 871b3b1..317bd1c 100644 --- a/common/cmd_nvedit.c +++ b/common/cmd_nvedit.c @@ -674,14 +674,40 @@ int envmatch(uchar *s1, int i2) return -1; }
-static int do_env_default(cmd_tbl_t *cmdtp, int flag, +static int do_env_default(cmd_tbl_t *cmdtp, int __flag, int argc, char * const argv[]) {
- if (argc != 2 || strcmp(argv[1], "-f") != 0)
- return cmd_usage(cmdtp);
- set_default_env("## Resetting to default environment\n");
- return 0;
- int all = 0, flag = 0;
blank line here
- debug("Initial value for argc=%d\n", argc);
- while (--argc > 0 && **++argv == '-') {
- char *arg = *argv;
blank line here
- while (*++arg) {
- switch (*arg) {
- case 'a': /* default all */
- all = 1;
- break;
- case 'f': /* force */
- flag |= H_FORCE;
- break;
- default:
- return cmd_usage(cmdtp);
- }
- }
- }
- debug("Final value for argc=%d\n", argc);
- if (all && (argc == 0)) {
- /* Reset the whole environment */
- set_default_env("## Resetting to default environment\n");
- return 0;
- }
+#ifdef CONFIG_CMD_DEFAULTENV_VARS
- if (!all && (argc > 0)) {
- /* Reset individual variables */
- env_default_vars(argc, argv);
- return 0;
- }
+#endif
blank line here
- return cmd_usage(cmdtp);
}
static int do_env_delete(cmd_tbl_t *cmdtp, int flag,
diff --git a/include/environment.h b/include/environment.h index 3a3e6b8..8f0d4db 100644 --- a/include/environment.h +++ b/include/environment.h @@ -190,6 +190,11 @@ void env_crc_update(void); /* [re]set to the default environment */ void set_default_env(const char *s);
+#ifdef CONFIG_CMD_DEFAULTENV_VARS +/* [re]set individual variables to their value in the default environment */ +int env_default_vars(int nvars, char * const vars[]);
How about env_set_vars_to_default?
Regards, Simon