3

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?

1

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.