-
Notifications
You must be signed in to change notification settings - Fork 455
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
expand macros for non-existant custom variable as empty string #984
expand macros for non-existant custom variable as empty string #984
Conversation
This looks to be the correct change. I'm curious what you think about having a similar logic for ALL macros? I'm curious if there are some negatives. The reason I ask is that some commands might use a macro that is only available in certain contexts, like the how |
I would appreciate that behavior, but did not grok how that purpose differentiation works - or I might simply have overlooked it. |
If I expand a non-existent shell variable I get a blank. I think the same behavior inside of a Nagios script makes sense. It would be up to me, the developer, to make sure that the variable is defined before I use it. So I am in 100% agreement that any non-existent macro should expand to a blank. |
What do we want to do here? This change seems to be welcomed. We could merge and be better off. @tsadpbb what would the effort look like to expand this to all macros? Would we want to offer an addition here or make a separate issue? |
It would involve modifying the following which can be found around line 195
|
If we made a change there does it remove the need for this PR/would it also address the custom variable issue? |
It is a little more complicated - one would want to ensure that each known prefix gets an "expand empty" shortcut, but the keeping unknown text that does not have one of the supported prefixes must not be replaced - else users could not put small inline bash scripts into macros, if they use |
You are right, upon reading some more of macros.c, I agree it is more complicated |
I noticed that when you have no custom variables defined for an object, this added logic is never met because vars is NULL when the object does not have any custom variables Near line 2470
Used in a context like follows
I would suggest changing the check to
Or doing something similar Also update the changelog to add this to version 4.5.6 |
@klaernie we're releasing 4.5.6 tomorrow, it doesn't look like your change here will make that, but I would like to get it included in 4.5.7 next month. May I ask, what do you think of the notes above? |
0d70776
to
a1db957
Compare
a1db957
to
e28b8db
Compare
Sorry, got swamped for a moment. I rebased on top of the current master branch, and incorporated the suggestion by @tsadpbb - thanks for catching that! Just in case this PR still makes it, I moved the changelog entry to 4.5.6, but in case that does not happen it's no problem to move it again. |
Hi @klaernie, Thanks for the update! I'll merge this now and move the changelog to 4.5.7 after the merge. Aaron |
Thanks, @aaronagios ! |
I hope adding the changelog entry to the topmost entry is the right place.