Reading env POSIX documentation:
Some have suggested that env is redundant since the same effect is achieved by:
name=value ... utility [ argument ... ]
The example is equivalent to env when an environment variable is being added to the environment of the command, but not when the environment is being set to the given value. The env utility also writes out the current environment if invoked without arguments. There is sufficient functionality beyond what the example provides to justify inclusion of env.
AFAICT, the above statement meaning var=value command will be the same as env var="value" command, and not when using as env -i var="value" command.
Now, at least with env implementation on GNU system, FreeBSD and Solaris 11, I realize that they're not equivalent, because env allow any characters, except = and \0 in var name:
$ env 'BASH_FUNC_foo%%=() { echo foo; }' bash -c foo
print foo, while you can't use BASH_FUNC_foo%%='() { echo foo; }' in any shells, because BASH_FUNC_foo%% clearly not a valid variable name.
In POSIX shells, except bash, this left a variable named BASH_FUNC_foo%% in environment variables, which the shell can not access it.
So, what is the purpose of allowing arbitrary name in form env var=value and was it allowed by POSIX?
envis a mistake.....especially including the python crowd's promotion of usingenvon the#!line of a script file. See unix.stackexchange.com/questions/29608/… for interesting debate on the topic.bash.rcthat allows anything in a variable name (and where all variables are exported).