### Description
Currently, an undefined environmental variable with `#!defenv` results in Kamailio failing to start. The proposal here that if the environmental variable is not defined, then the macro value would be undefined as well. For example:
``` !#KAMAILIO loadmodule "xlog" loadmodule "pv"
#!defenv FOO
request_route { #!ifdef FOO xlog("L_INFO","Environmental variable $$FOO is set\n"); #!else xlog("L_WARN","Environmental variable $$FOO is NOT set\n"); #!endif forward(); } ```
Currently this configuration will fail to load if environmental variable is not set. My proposal is to either allow `#!envdef` to accept an undefined environmental variable and have the preprocessor macro undefined, or to add a new keyword (`#!envdefn` perhaps?) to allow this behavior.
I've forked and written a patch to add `#!defenvn` , as well `#!defenvns` to auto quote the value based on the new `#!defenvs`, however in testing it appears that `#!defenvs` is not working. I'm not sure in what order you'd like to have the PR submitted: I can submit now with both `#!defenvs` and `#!defenvns` not working, or I can wait for (or possibly fix) `#!defenvs` and then rebase my changes off of that.
Thoughts?
Proposed changes are in https://github.com/whosgonna/kamailio/tree/iss2967
As indicated by @miconda, I've refactored the keywords from `defenvn` to `trydefenv` and from `defenvs` to `trydefenvns`.
@miconda indicated in the Kamailio mailing list that they code for `#!defenvs` would be pushed. Once that's done, I'll merge to my fork, then submit a PR.
PR was merged.
Closed #2967.