actions / actions/toolkit

The `exec` action hangs when last argument is enclosed in double quotes

Open
#1,119 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
TypeScript
Stars
5.9k
Forks
1.8k
PR merge metrics
No merged PRs in 30d

Description

Describe the bug
As part of a custom action I'm writing, I'm trying to use the exec action to run ripgrep in the following way:

rg --type rust --files-without-match --fixed-strings "Copyright (C) 2022 MaidSafe."

I'm attempting to do this using the exec action:

async function runRipGrep(searchString) {
  let output = '';
  const options = {};
  options.listeners = {
    stdout: (data) => {
      output += data.toString();
    }
  };
  await exec.exec(
    'rg',
    [
      '--type', 'rust', '--files-without-match',
      '--fixed-strings', `"${searchString}"`
    ],
    options);
  return output;
}

When exec runs as above, it hangs indefinitely until the workflow run is cancelled.

To Reproduce
Invoke rg using the mechanism above.

Expected behavior
The process should run and return its output.

Additional context
I tried different ways of running it. Curiously, if you add an additional argument after the double quotes enclosed argument, exec does return:

async function runRipGrep(searchString) {
  let output = '';
  const options = {};
  options.listeners = {
    stdout: (data) => {
      output += data.toString();
    }
  };
  await exec.exec(
    'rg',
    [
      '--type', 'rust', '--files-without-match',
      '--fixed-strings', `"${searchString}"`, '.'
    ],
    options);
  return output;
}

However, the process doesn't produce the same output as per executing it from the shell, which may suggest the double quotes are causing some sort of parsing issue. It's almost like the search string is not supplied.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the TypeScript toolkit's exec.exec entry point and reproduce the provided ripgrep invocation with the quoted final argument. Trace how the argument list is passed to the process, then verify that the command returns without hanging and produces the expected output when the quoted argument is last.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.