On 29/03/2024 11:23, Pádraig Brady wrote:
On 29/03/2024 05:05, Kaz Kylheku wrote:
On 2024-03-28 15:29, Balakrishnan Balasubramanian wrote:
On 2024-03-28 3:38 p.m., Pádraig Brady wrote:
Yes the feature has merit, and was previously discussed at:
https://lists.gnu.org/archive/html/coreutils/2021-10/msg00001.html
There are some subtleties to consider though.

Indeed there are subtleties to consider. Thank you pointing previous discussion.
For the first revision, it can be stricter but leave room for improved features 
later without breaking backwards compatibility.

1. Support empty lines comments in separate lines.

      <optional whitespace># comment text

In my opinion, the file should have exactly the same format as /proc/environ on 
Linux.

env-file := { var-name '=' { non-null-byte } * '\0'} *

I.e. we already have a widely used data format in which environments are 
represented as files, albeit virtual ones.

No need to invent anything.

4. Literal backslah (\) should be escaped. Otherwise error

No escaping nonsense. Null termination is all the escape you need.

An interesting suggestion thanks.
Note env also has the -0 option, which might enable that mode?

Referencing the later thread for my previous thoughts on the subject:
https://lists.gnu.org/archive/html/coreutils/2022-01/msg00033.html

This patch set adds --env0-from to the env(1) command.

https://github.com/pixelb/coreutils/compare/env0-from

This supports efficient round tripping from the output of `env -0`,
which may contain non standard environment entries without '=' etc.

Note the naming was chosen to be descriptive and consistent form
with the existing --files0-from option in various commands.

The trigger for doing this now was the request to support regex filtering
of environment entries, which can now be achieved more generally
and robustly with something like:

  env -i --env0-from=<( env -0 | sed -z ... )

For textual environment files, one can leverage sh to parse and exec,
which gives support for comments, interpolation etc. which there
is no need for env(1) to re-implement, though a subset of that
functionality is available through the -S option if required.

cheers,
Padraig

Reply via email to