Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the isShellCommand property actually do and how should you use it?

What does the isShellCommand property actually do and how should you use it?

The description when hovering says:

"Specifies whether the command is a shell command or an external programm. Defaults to false if omitted"

And in https://code.visualstudio.com/Docs/editor/tasks they mention it in the example with:

"We want to run the gulp command in a shell (VS Code directly executing it) so we used isShellCommand"

So what is the difference between a shell command vs external program?

Does running with isShellCommand = false mean that vsCode will not be "directly executing it" meaning it will run the "command" and don´t listen to any output from it (because it ran it as an external command?) which in turn means we cannot use problem matchers.

Or if setting isShellCommand = true does it mean that vscode is "directly executing it" and will keep track of it and listen to the output generated so we can use problem matchers etc to integrate with vsCode?

Considering the example below using tsc to compile a typescript project:

c:\Users\J\Code\vscode-project>where tsc

C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.4\tsc.exe
C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.4\tsc.js
C:\Users\J\AppData\Roaming\npm\tsc
C:\Users\J\AppData\Roaming\npm\tsc.cmd

And the following task.json

{
    "version": "0.1.0",

    // The command is tsc. Assumes that tsc has been installed using npm install -g typescript
    "command": "tsc",

    // The command is a shell script
    "isShellCommand": false,

    "args": ["-v"],

    "problemMatcher": "$tsc"
}

If I run the task now it will output version:

message TS6029: Version 1.4.0.0

And if I change isShellCommand to true it will output same

message TS6029: Version 1.4.0.0

So my thought was if I change to calling an external program by setting isShellCommand to true and calling an .exe file it will not give me any output but it does?!.

{
    ...
    "command": "tsc.cmd"
    "isShellCommand": true,
}
message TS6029: Version 1.4.0.0

So under which circumstances should you set isShellCommand to true/false?

Been trying to find more information about all this in vsCode documents but could not find anything, so if anyone could point me to any resources besides https://code.visualstudio.com/Docs I would be really grateful aswell. Thanks

like image 971
dohjon Avatar asked Sep 02 '25 07:09

dohjon


1 Answers

Found the answer(s) I was seeking in: https://github.com/Microsoft/vscode-docs/blob/master/docs/editor/tasks_appendix.md

/**
 * Specifies whether the command is a shell command and therefore must
 * be executed in a shell interpreter (e.g. cmd.exe, bash, ...).
 *
 * Defaults to false if omitted.
 */
isShellCommand?: boolean;
like image 77
dohjon Avatar answered Sep 04 '25 21:09

dohjon