env - linux

Issue with env trying to evaluate its values with spaces

Trying to run commands like this:

env - $(env; cat /my/env/file)

Errors out when certain env variables have spaces in their values.

For example:

SSH_CONNECTION=<ip> 52002 <ip> 22

Instead of just being printed out with cat, since they have spaces they attempt to evaluate the string as a command.

For now, my solution is to just set the known variables to
blank strings in a custom mini shell script called "add-to-env"
which takes an arbitrary number of files as arguments to add to the env
for the singular command

Example usage:

$ env - $(add-to-env /path/to/my/env/file) my-command