[SR-Users] Unquoted values from #!defenv

Ben Kaufman bkaufman at nexvortex.com
Tue Nov 30 22:40:07 CET 2021


Hello all,

Looking for some clarification regarding quoting and !#defenv .  I understand that the example below fails because the environmental variable HOME is not quoted, thus when used in the xlog() call it fails.  How is it possible to evaluate and/or use the value of the environmental variable if defined as a preprocessor variable?  Looking at the documentation the reason for this directive is "It is a simplified alternative of using #!substdef with $env(NAME) in the replacement part." But #!substdef would allow setting the value inside of a quoted string, so does it really meet that requirement?

I'm aware that I could use $env(HOME) rather than a preprocessor directive of HOME.  I'm just trying to understand the usage of the #!defenv feature.


#!KAMAILIO
## Tested in 5.5.2
loadmodule "xlog"
loadmodule "pv"
loadmodule "evrexec"

modparam("evrexec", "exec", "name=evrexec:timer;wait=1000;workers=1;")

#!defenv HOME

request_route{
    forward();
}

event_route[evrexec:timer] {
    xlog("L_N", "HOME: " + HOME + "\n");
}


Ben Kaufman


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-users/attachments/20211130/41af3687/attachment.htm>


More information about the sr-users mailing list