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

Heredoc with hyphen strips extra newlines

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: PUP 4.10.8, PUP 5.3.1
    • Component/s: None
    • Labels:
      None
    • Environment:

      Puppet 5.1.0
      OS X 10.12.6

    • Template:
    • Acceptance Criteria:
      Hide

      With suppression (-END)

      ❯ cat test.pp 
      notice(@(END))
      line1
      line2
       
      line4
      -END
      ❯ puppet apply test.pp
      Notice: Scope(Class[main]): line1
      line2
       
      line4
      Notice: Compiled catalog for marla.local in environment production in 0.03 seconds
      Notice: Applied catalog in 0.01 seconds
      

      Show
      With suppression (-END) ❯ cat test.pp notice(@(END)) line1 line2   line4 -END ❯ puppet apply test.pp Notice: Scope(Class[main]): line1 line2   line4 Notice: Compiled catalog for marla.local in environment production in 0.03 seconds Notice: Applied catalog in 0.01 seconds
    • Team:
      Platform Core
    • Story Points:
      1
    • Method Found:
      Customer Feedback
    • Release Notes:
      Bug Fix
    • Release Notes Summary:
      Hide
      When a heredoc ended with a tag preceeded by '-' (minus) to indicate that the final newline should be removed from the result, not only did it remove the last newline, but also reduce all multiple empty lines into single empty lines in the entire text. This is now fixed so only the single last trailing newline is removed.
      Show
      When a heredoc ended with a tag preceeded by '-' (minus) to indicate that the final newline should be removed from the result, not only did it remove the last newline, but also reduce all multiple empty lines into single empty lines in the entire text. This is now fixed so only the single last trailing newline is removed.
    • QA Risk Assessment:
      Needs Assessment

      Description

      A heredoc set to suppress the final line break also converts double line breaks into single line breaks.

      Without suppression (END)

      ❯ cat test.pp 
      notice(@(END))
      line1
      line2
       
      line4
      END
      ❯ puppet apply test.pp 
      Notice: Scope(Class[main]): line1
      line2
       
      line4
       
      Notice: Compiled catalog for marla.local in environment production in 0.03 seconds
      Notice: Applied catalog in 0.01 seconds
      

      With suppression (-END)

      ❯ cat test.pp 
      notice(@(END))
      line1
      line2
       
      line4
      -END
      ❯ puppet apply test.pp
      Notice: Scope(Class[main]): line1
      line2
      line4
      Notice: Compiled catalog for marla.local in environment production in 0.03 seconds
      Notice: Applied catalog in 0.01 seconds
      

      -END should only supress the final line break.

        Attachments

          Activity

          Hide
          henrik.lindberg Henrik Lindberg added a comment -

          You are right, the '-' removes all the trailing new lines. This shows what happens a bit clearer:

          cat pup7902.pp
          notice("# The result should have one new line at the end")
          notice(String(@(END),"%p"))
          line1
          line2
           
          line4
           
          -END
           
          notice("# The result should have two new line at the end")
          notice(String(@(END),"%p"))
          line1
          line2
           
          line4
           
           
          -END
          <EOF>
          puppet apply pup7902.pp
          

          Results in:

          Notice: Scope(Class[main]): # The result should have one new line at the end
          Notice: Scope(Class[main]): "line1\nline2\nline4"
          Notice: Scope(Class[main]): # The result should have two new line at the end
          Notice: Scope(Class[main]): "line1\nline2\nline4"
          Notice: Compiled catalog for henrik2 in environment production in 0.04 seconds
          

          Show
          henrik.lindberg Henrik Lindberg added a comment - You are right, the '-' removes all the trailing new lines. This shows what happens a bit clearer: cat pup7902.pp notice("# The result should have one new line at the end") notice(String(@(END),"%p")) line1 line2   line4   -END   notice("# The result should have two new line at the end") notice(String(@(END),"%p")) line1 line2   line4     -END <EOF> puppet apply pup7902.pp Results in: Notice: Scope(Class[main]): # The result should have one new line at the end Notice: Scope(Class[main]): "line1\nline2\nline4" Notice: Scope(Class[main]): # The result should have two new line at the end Notice: Scope(Class[main]): "line1\nline2\nline4" Notice: Compiled catalog for henrik2 in environment production in 0.04 seconds
          Hide
          thomas.hallgren Thomas Hallgren added a comment -

          Please note that it doesn't remove just trailing newlines. It removes all empty lines, regardless where in the text they are.

          Show
          thomas.hallgren Thomas Hallgren added a comment - Please note that it doesn't remove just trailing newlines. It removes all empty lines, regardless where in the text they are.
          Hide
          henrik.lindberg Henrik Lindberg added a comment -

          merged to 4.10.x, but awaits merging up because of other PR's in flight with merge ups...

          Show
          henrik.lindberg Henrik Lindberg added a comment - merged to 4.10.x, but awaits merging up because of other PR's in flight with merge ups...
          Hide
          kenn Kenn Hussey added a comment -

          Henrik Lindberg please provide release notes for this issue, if needed. Thanks!

          Show
          kenn Kenn Hussey added a comment - Henrik Lindberg please provide release notes for this issue, if needed. Thanks!
          Hide
          sean.mcdonald Sean McDonald added a comment - - edited

          Passed 1.10.x acceptance at puppet-agent cd508fca2c04ef660cc2844832bf72259d80af2e

          Show
          sean.mcdonald Sean McDonald added a comment - - edited Passed 1.10.x acceptance at puppet-agent cd508fca2c04ef660cc2844832bf72259d80af2e
          Hide
          kenn Kenn Hussey added a comment -

          Eric Delaney has this made it through CI?

          Show
          kenn Kenn Hussey added a comment - Eric Delaney has this made it through CI?
          Hide
          kenn Kenn Hussey added a comment -

          Eric Delaney can this be resolved now that the release has shipped?

          Show
          kenn Kenn Hussey added a comment - Eric Delaney can this be resolved now that the release has shipped?

            People

            • Assignee:
              Unassigned
              Reporter:
              daniel.parks Daniel Parks
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Zendesk Support