Toolkit: Pipes not working in @actions/exec node module

Created on 20 Feb 2020  路  4Comments  路  Source: actions/toolkit

Describe the bug
It looks like @actions/exec.exec escapes commands and pipes are not working because of this

To Reproduce
Steps to reproduce the behavior:

  1. Create a new javascript action
  2. Add @actions/exec to project - npm i -s @actions/exec
  3. In your index file add any .exec command with pipe, ie: echo "Hello world" | grep "o"
  4. It would print Hello world" | grep "o", instead of Hell**o** w**o**rld (asterisks here are only for visual purpose, i do not expect them to be in log)
    Screenshot 2020-02-20 at 10 22 40

Expected behavior
Have an option to disable escaping

Screenshots
image

Desktop (please complete the following information):

  • OS: tested on macOS-latest machine
  • Browser [e.g. chrome, safari]
  • Version @actions/[email protected]
bug

Most helpful comment

@Kerizer I have the same problem, the command I want to run is yes | sdkmanager --licenses to automatically accept all prompts with yes. This does not work, it takes | sdkmanager --licenses as one argument and prints that forever until I cancel the workflow.

A workaround I found is to use /bin/bash -c "my command" , e.g. /bin/bash -c "yes | sdkmanager --licenses". That worked for me.

All 4 comments

@Kerizer I have the same problem, the command I want to run is yes | sdkmanager --licenses to automatically accept all prompts with yes. This does not work, it takes | sdkmanager --licenses as one argument and prints that forever until I cancel the workflow.

A workaround I found is to use /bin/bash -c "my command" , e.g. /bin/bash -c "yes | sdkmanager --licenses". That worked for me.

As I just found out, this also affects chaining commands with &&...

@hrueger Thanks a lot for the workaround. For future reference here is the windows equivalent:

WINDOWS:

exec.exec(`cmd /c "my command"`)
Was this page helpful?
0 / 5 - 0 ratings