cmd/nvedit.c: teach 'env default' to optionally keep runtime variables
authorRasmus Villemoes <ravi@prevas.dk>
Wed, 30 Oct 2024 21:34:02 +0000 (22:34 +0100)
committerTom Rini <trini@konsulko.com>
Fri, 15 Nov 2024 22:36:18 +0000 (16:36 -0600)
commit4d28fcdf65950576f0e0f5447c89421126dc4943
tree9c710b4c65110058012846c4eabdea4344c0ea7e
parent84b95e918942d0e29e3634d265694030f76faf5a
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>
cmd/nvedit.c