2

Task commands in my tasks.json file are getting long. These tasks are mostly docker tasks, for example:

{
    "label": "Test",
    "command": "docker run -t --rm --group-add $(stat -c '%g' /var/run/docker.sock) ..."
    ...
}

The value for "command" key is long, so to make the tasks more readable, I tried using another approach for executing the command, but this does not work for my scenario:

{
    "command": "docker"
    "args": ["run", "-t", "--rm",
        "--group-add", "${stat -c '%g'} /var/run/docker.sock"
        ...     
    ]
}

In the first case, the output from stat -c '%g' /var/run/docker.sock is correctly set for --group-add. However, in the second case, the stat command will not be evaluated and whatever string is placed there is passed as the argument. Is it possible to obtain the shell commands output in some way and use the second approach for writing tasks.json file?

Ankit Koirala
  • 354
  • 3
  • 13
  • 1
    see https://marketplace.visualstudio.com/items?itemName=augustocdias.tasks-shell-input via https://stackoverflow.com/a/58930746 – user326608 Jul 13 '20 at 12:55

0 Answers0