Consider I want to programmatically read the environment of an interactive shell. Now, starting a shell, running /usr/bin/env and capturing its output seems like a good solution. But only up until the moment we realize that variable values can have line breaks:
$ export LINE0='VALUE0
> LINE1=VALUE1'
$ env | grep ^LINE
LINE0=VALUE0
LINE1=VALUE1
So capturing the output of env -0 (NULL-separated entries) seems like a better approach, but this only applies to GNU env, so is mostly Linux-specific.
Is there any portable (POSIX or BSD) way to get the NULL-separated list of environment variables, using only the standard command line tools (may use awk, but no perl/python/ruby allowed)?
printenvfor just one example.