From the man page:
Quote:
int
setenv(const char *name, const char *value, int overwrite);
The setenv() function inserts or resets the environment variable name in
the current environment list. If the variable name does not exist in the
list, it is inserted with the given value. If the variable does exist,
the argument overwrite is tested; if overwrite is zero, the variable is
not reset, otherwise it is reset to the given value.
|
Looking at the source code for openbsd 3.5, one sees that not only can setenv be used in the form:
Code:
setenv("dog", "spot", 1)
but also in the form:
Code:
setenv("dog=spot", "spot", 1)
since any characters in
name following an equal sign '=' (including the equal sign) are ignored by setenv.
As far as I can tell, this is not documented.
The man page does mention that
name and
value may be appended and prepended, respectively, with an equal-sign, so that the string "spot" in the above example may be replaced with "=spot" without any harm. (However, "spot" may not be replaced with "xxx=spot", since an equal-sign in
value is ignored only in the case that the equal sign is the first character in the
value string.
As such, this isn't a big deal. But, a look at the source code for
env(1) reveals that this undocumented feature of setenv is being used: something of the form
Code:
env name=value command
is implemented by doing a setenv("name=value", "value", 1) rather than putenv("name=value") before calling an exec function to run command.
Seems to me this feature of setenv should be documented if it is to be used.