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

exec command fails if command is single word with trailing newline

    Details

    • Type: Bug
    • Status: Accepted
    • Priority: Normal
    • Resolution: Unresolved
    • Affects Version/s: PUP 3.8.7
    • Fix Version/s: None
    • Component/s: Types and Providers
    • Labels:
    • Environment:

      Hiera

    • Template:
    • Epic Link:
    • Team:
      Coremunity
    • QA Risk Assessment:
      Needs Assessment

      Description

      Using erwbgy-system module to associate hiera hash entries with types, I have the following construct:

      (Be not confused in following examples: `true` is a standard posix command and does not mean a boolean value here.)

      First, a few baselines:
      ```
      system::execs:
      'test-OK-1':
      command: "true"

      'test-OK-2':
      command: >-
      true

      'test-OK-3':
      command: |-
      true

      'test-OK-4':
      command: >
      echo true

      'test-OK-5':

      1. note, trailing whitespace after "echo" below
        command: >
        echo

      'test-OK-6':

      1. note, command broken on two lines
        command: >
        echo
        true
        ```

      Here is what DOES NOT work:
      ```
      system::execs:
      'test1-BAD':
      command: >
      true

      'test2-BAD':
      command: |
      true
      ```

      Results in ```
      Error: /Stage[main]/System::Execs/Exec[test123]: Could not evaluate: Could not find command 'true
      '
      ```

      We get similar errors if the command is command is in attributes `onlyif`, `unless`.

      The combined examples demonstrate that trailing whitespace is ignored/stripped, but trailing newlines are not. This is unexpected behavior. The problem probably arises from provider's validation step to ensure the command exists; this has always been dubious and incorrect (IMHO) behavior: just try and run the thing; it does no one any good to determine what the OS will report.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              otheus otheus
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:

                Zendesk Support