Like setenv(), but automatically marks the entry as "don't export".

Signed-off-by: Bernhard Nortmann <bernhard.nortm...@web.de>
---

 cmd/nvedit.c     | 21 +++++++++++++++++++++
 include/common.h |  1 +
 2 files changed, 22 insertions(+)

diff --git a/cmd/nvedit.c b/cmd/nvedit.c
index 88dbcb9..3c408f6 100644
--- a/cmd/nvedit.c
+++ b/cmd/nvedit.c
@@ -300,6 +300,27 @@ int setenv(const char *varname, const char *varvalue)
 }
 
 /**
+ * Set a "transient" environment variable
+ *
+ * Like setenv(), but this automatically marks the
+ * resulting entry as transient (= "do not export").
+ */
+int setenv_transient(const char *varname, const char *varvalue)
+{
+       int rc = setenv(varname, varvalue);
+       if (rc == 0) {
+               ENTRY e, *ep;
+
+               e.key = varname;
+               e.data = NULL;
+               hsearch_r(e, FIND, &ep, &env_htab, 0);
+               if (ep)
+                       ep->flags |= ENV_FLAGS_VARACCESS_PREVENT_EXPORT;
+       }
+       return rc;
+}
+
+/**
  * Set an environment variable to an integer value
  *
  * @param varname      Environment variable to set
diff --git a/include/common.h b/include/common.h
index 3feaae6..a8e019a 100644
--- a/include/common.h
+++ b/include/common.h
@@ -380,6 +380,7 @@ ulong getenv_hex(const char *varname, ulong default_val);
 int getenv_yesno(const char *var);
 int    saveenv      (void);
 int    setenv       (const char *, const char *);
+int    setenv_transient(const char *, const char *);
 int setenv_ulong(const char *varname, ulong value);
 int setenv_hex(const char *varname, ulong value);
 /**
-- 
2.7.3

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to