Skip to content
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

For multiline commands, only use the first line and "..." as the label #321

Merged
merged 2 commits into from
Apr 19, 2022

Conversation

andrewshadura
Copy link
Contributor

When a multiline command is used with "run" action, it’s sometimes
difficult to figure out what’s going on, as it’s printed in its entirety
for the each line of its own output. For example:

  - action: run
    chroot: false
    command: |
      echo test1
      echo test2
      echo test3

Prints this:

2022/04/15 10:52:46 echo test1
echo test2
echo test3
 | test1
2022/04/15 10:52:46 echo test1
echo test2
echo test3
 | test2
2022/04/15 10:52:46 echo test1
echo test2
echo test3
 | test3

For clarity, it’s better to only use the first line:

2022/04/15 11:03:10 echo test1... | test1
2022/04/15 11:03:10 echo test1... | test2
2022/04/15 11:03:10 echo test1... | test3

When a multiline command is used with "run" action, it’s sometimes
difficult to figure out what’s going on, as it’s printed in its entirety
for the each line of its own output. For example:

    actions:
      - action: run
        chroot: false
        command: |
          echo test1
          echo test2
          echo test3

Prints this:

    2022/04/15 10:52:46 echo test1
    echo test2
    echo test3
     | test1
    2022/04/15 10:52:46 echo test1
    echo test2
    echo test3
     | test2
    2022/04/15 10:52:46 echo test1
    echo test2
    echo test3

For clarity, it’s better to only use the first line:

    2022/04/15 11:03:10 echo test1... | test1
    2022/04/15 11:03:10 echo test1... | test2
    2022/04/15 11:03:10 echo test1... | test3

Signed-off-by: Andrej Shadura <[email protected]>
actions/run_action.go Show resolved Hide resolved
Very long commands clutter the logs too, so shortening them up should
also be helpful:

      - action: run
        chroot: false
        command: |
          echo test1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
          echo test2
          echo test3

It will print this:

    2022/04/15 15:24:49 echo test1 2 3 4 5 6 7 8 9 10 11 12 13 1... | test1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
    2022/04/15 15:24:49 echo test1 2 3 4 5 6 7 8 9 10 11 12 13 1... | test2
    2022/04/15 15:24:49 echo test1 2 3 4 5 6 7 8 9 10 11 12 13 1... | test3

On the other hand, a single-line command written as a multiline string
is still a single-line command:

      - action: run
        chroot: false
        command: |
          echo test1

Should print:

    2022/04/15 15:29:27 echo test1 | test1

Signed-off-by: Andrej Shadura <[email protected]>
@obbardc obbardc added this to the v1.1.0 milestone Apr 15, 2022
@sjoerdsimons sjoerdsimons merged commit aac4596 into go-debos:master Apr 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants