Uploaded image for project: 'Puppet'
  1. Puppet
  2. PUP-4331

should warn on checking an empty string in defined()

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Normal
    • Resolution: Duplicate
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Template:
    • Epic Link:
    • Story Points:
      1
    • Sprint:
      Language 2015-04-29

      Description

      [root@dk18o2lqr8zz05t ~]# puppet apply -e 'notice(defined(""))'
      Notice: Scope(Class[main]): true
      

      This is surprising since asking if an undefined variable is defined and using double quotes - e.g. defined("$not_defined") has the unfortunate result true since the puppet main class is internally called '' (an empty string since it is the first name segment (the text "before" the :: in a qualified name.

      The documentation should at least point this anomaly out. A better solution may be to error and instead support asking for "main". The rationale is that it is meaningless to ask if the root name space is defined since it is always present so it can be considered an error to ask this obvious question in favor of helping those that forget to escape the $ in a double quoted string when asking if a variable is defined.

        Attachments

          Issue Links

            Activity

              jsd-sla-details-panel

                People

                • Assignee:
                  Unassigned
                  Reporter:
                  erict Eric Thompson
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  2 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: