Subject: Re: bug#12964: [PATCH] printenv: -n option added -- show names of variables.

From: Bernhard Voelker <[email-masked]>
Date: Wed, 10 Oct 2018 11:03:05 +0200

On 10/9/18 11:33 PM, Assaf Gordon wrote:
> With your patch, using "printenv -n VARNAME" adds
> the variable name to the output. e.g.:
> 
>     $ printenv HOME
>     /home/gordon
> 
>     $ printenv -n HOME
>     HOME=/home/gordon
> 
> From a cursory look this seems like a non-standard extension
> that is not available in any other 'printenv' implementations.

This feature looks like it should be possible to write out the current settings
to a file which could later be sourced in:

  printenv -n VAR > file

and in another shell (to get VAR back):

  . file

I'm afraid this is problematic once the value of a variable starts to have
funny characters, even a simple blank ' ' already screws things up.
For this kind of save/restore, -n would need to do correct shell quoting.

Have a nice day,
Berny