Is it possible to use a variable from one configuration in a included
config file? Example:
set $a = "hello";
include test.conf;
[test.conf]
if ($a = "hello") {
set $a = "world";
}
# something that works with $a
Within the scope of the commands of test.conf, will $a be "hello" or
"world"? Currently my usage like this gives me a, "using unitialized
variable" warning.
--
Daniel
on 2013-01-13 06:41
on 2013-01-14 03:51
Hello! On Sat, Jan 12, 2013 at 09:40:14PM -0800, Daniel L. Miller wrote: > # something that works with $a > > Within the scope of the commands of test.conf, will $a be "hello" or > "world"? Currently my usage like this gives me a, "using > unitialized variable" warning. The "include" directive works during configuration parsing and completely transparent to everything else. That is, you may set a variable in one file and then use it in an included file, it is expected to work fine. On the other hand, example you've provided is syntactically invalid and will result in the following error during configuration parsing: nginx: [emerg] invalid number of arguments in "set" directive in ... Correct way to write it would be set $a "hello"; Note there is no "=" character. See http://nginx.org/r/set for details. Note well, that after fixing the example the $a at the end of test.conf will be either "world" (if test.conf goes after 'set $a "hello";') or uninitialized if it's included somewhere else. -- Maxim Dounin http://nginx.com/support.html
on 2013-01-14 05:18
On 1/13/2013 6:50 PM, Maxim Dounin wrote: >> [test.conf] > variable in one file and then use it in an included file, it is > set $a "hello"; > > Note there is no "=" character. See http://nginx.org/r/set for > details. Shows what happens when you quickly type up an example...thanks for catching it. So I repeat my question - why, given the above example (with correct syntax), would I see warnings for "uninitialized variable" for the above in the "test.conf", as the variable is declared prior to the include statement? -- Daniel
on 2013-01-14 12:10
Hello! On Sun, Jan 13, 2013 at 08:18:35PM -0800, Daniel L. Miller wrote: > >> > >completely transparent to everything else. That is, you may set a > > > include statement? Because of another problem resulted from quick typing? Show the exact configuration which produces warning for you. -- Maxim Dounin http://nginx.com/support.html
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.