Issue #12479 has been updated by Nicolas Simonds.
A workaround from the manifest side, for those of us who get our software from
upstream packages and don't modify it:
case $schrodingers_fact {
/^undef$/: { notice("do the non-matching stuff here") }
/\w/: { notice("do the non-matching stuff here") }
default: { notice("do the non-matching stuff here") }
}
Yes, it's icky, and it involves repeating repeating yourself. That's why they
call them bugs.
----------------------------------------
Bug #12479: Regular expression matching against an undefined variable results
in matching the string `undef`
https://projects.puppetlabs.com/issues/12479
Author: Nicolas Simonds
Status: In Topic Branch Pending Review
Priority: Normal
Assignee:
Category: parser
Target version: 2.7.x
Affected Puppet version: 2.6.0
Keywords:
Branch: https://github.com/puppetlabs/puppet/pull/470
Non-existent variables are stringify-ing under the hood as `"undef"`, which
causes them to match regexes, despite behaving like nil or the empty string
when otherwise asked.
A simple demonstration manifest:
<pre>
case $wtf { "undef": { notice("matched string undef") } }
case $wtf { /^undef$/: { notice("matched regexp undef") } }
case $wtf { "": { notice("matched empty string") } }
case $wtf { undef: { notice("matched bareword undef") } }
</pre>
Expected result:
All notices that the non-existent fact or variable doesn't match.
Actual result:
Various and sundry notices that it matched. BAD PUPPET! NO COOKIE!
All die of embarrassment.
--
You have received this notification because you have either subscribed to it,
or are involved in it.
To change your notification preferences, please click here:
http://projects.puppetlabs.com/my/account
--
You received this message because you are subscribed to the Google Groups
"Puppet Bugs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/puppet-bugs?hl=en.