Skip to content

Commit 49c91c5

Browse files
committed
add property for controlling escaping arguments for the runInTerminal request
Fixes #146
1 parent 5286b33 commit 49c91c5

File tree

3 files changed

+31
-5
lines changed

3 files changed

+31
-5
lines changed

debugAdapterProtocol.json

+9-1
Original file line numberDiff line numberDiff line change
@@ -734,14 +734,18 @@
734734
"allOf": [ { "$ref": "#/definitions/Request" }, {
735735
"type": "object",
736736
"title": "Reverse Requests",
737-
"description": "This optional request is sent from the debug adapter to the client to run a command in a terminal.\nThis is typically used to launch the debuggee in a terminal provided by the client.\nThis request should only be called if the client has passed the value true for the 'supportsRunInTerminalRequest' capability of the 'initialize' request.",
737+
"description": "This optional request is sent from the debug adapter to the client to run a command in a terminal.\nThis is typically used to launch the debuggee in a terminal provided by the client.\nThis request should only be called if the client has passed the value true for the 'supportsRunInTerminalRequest' capability of the 'initialize' request.\nClient implementations of runInTerminal are free to run the command however they choose including issuing the command to a command line interpreter (aka 'shell'). Argument strings passed to the runInTerminal request must arrive verbatim in the command to be run. As a consequence, clients which use a shell are responsible for escaping any special shell characters in the argument strings to prevent them from being interpreted (and modified) by the shell\nSome users may wish to take advantage of shell processing in the argument strings. For clients which implement runInTerminal using an intermediary shell, the argsCanBeInterpretedByShell property can be set to true. In this case the client is requested not to escape any special shell characters in the argument strings.",
738738
"properties": {
739739
"command": {
740740
"type": "string",
741741
"enum": [ "runInTerminal" ]
742742
},
743743
"arguments": {
744744
"$ref": "#/definitions/RunInTerminalRequestArguments"
745+
},
746+
"argsCanBeInterpretedByShell": {
747+
"type": "boolean",
748+
"description": "This property should only be set if the client has passed the value true for the 'supportsArgsCanBeInterpretedByShell' capability of the 'initialize' request. If the client uses an intermediary shell to launch the application, then the client must not attempt to escape characters with special meanings for the shell. The user is fully responsible for escaping as needed and that arguments using special characters may not be portable across shells."
745749
}
746750
},
747751
"required": [ "command", "arguments" ]
@@ -3146,6 +3150,10 @@
31463150
"supportsSingleThreadExecutionRequests": {
31473151
"type": "boolean",
31483152
"description": "The debug adapter supports the 'singleThread' property on the execution requests ('continue', 'next', 'stepIn', 'stepOut', 'reverseContinue', 'stepBack')."
3153+
},
3154+
"supportsArgsCanBeInterpretedByShell": {
3155+
"type": "boolean",
3156+
"description": "The debug adapter supports the 'argsCanBeInterpretedByShell' attribute on the 'runInTerminal' request."
31493157
}
31503158
}
31513159
},

overview.md

+1-4
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,7 @@ After the debug adapter has been initialized, it is ready to accept requests for
131131
Two requests exist for this:
132132
- [**launch**](./specification#Requests_Launch) request: the debug adapter launches the program ("debuggee") in debug mode and then starts to communicate with it.
133133
Since the debug adapter is responsible for the debuggee, it should provide options for the end user to interact with the debuggee.
134-
Basically there are three options how the debuggee can be launched. Two of the options are available to the debug adapter via the [**RunInTerminal**](./specification#Reverse_Requests_RunInTerminal) request.
135-
- the **_debug console_**: this is an interactive REPL environment which allows the user to evaluate expressions in the context of the debuggee. Program output shows up in the debug console too, but the program cannot read input through it (because of the REPL functionality).
136-
- an **_integrated terminal_**: this is a terminal emulator integrated in the development tool. It supports the usual terminal control codes and supports reading program input.
137-
- in an **_external terminal_**: similar to the integrated terminal, but the terminal runs outside of the development tool.
134+
- Debug adapters are free to launch the debuggee however they choose. Typically the debuggee is launched as a child process and its output channels are connected to a client's debug console via [**output**](./specification.md#Events_Output) events. However, this has certain limitations, such as not being able to write to the terminal device directly and not being able to accept standard input. For those cases, launching the debuggee in a terminal is preferable. A debug adapter can use the the [**runInTerminal**](./specification#Reverse_Requests_RunInTerminal) request to ask the client to launch the debuggee in a terminal that is integrated into the client or in a terminal that runs outside of the client (but still configured and managed from the client).
138135
- [**attach**](./specification#Requests_Attach) request: the debug adapter connects to an already running program. Here the end user is responsible for launching and terminating the program.
139136

140137
Since arguments for both requests are highly dependent on a specific debugger and debug adapter implementation, the Debug Adapter Protocol does not specify any arguments for these requests.

specification.md

+21
Original file line numberDiff line numberDiff line change
@@ -796,11 +796,26 @@ This is typically used to launch the debuggee in a terminal provided by the clie
796796

797797
This request should only be called if the client has passed the value true for the 'supportsRunInTerminalRequest' capability of the 'initialize' request.
798798

799+
Client implementations of runInTerminal are free to run the command however they choose including issuing the command to a command line interpreter (aka 'shell'). Argument strings passed to the runInTerminal request must arrive verbatim in the command to be run. As a consequence, clients which use a shell are responsible for escaping any special shell characters in the argument strings to prevent them from being interpreted (and modified) by the shell
800+
801+
Some users may wish to take advantage of shell processing in the argument strings. For clients which implement runInTerminal using an intermediary shell, the argsCanBeInterpretedByShell property can be set to true. In this case the client is requested not to escape any special shell characters in the argument strings.
802+
799803
```typescript
800804
interface RunInTerminalRequest extends Request {
801805
command: 'runInTerminal';
802806

803807
arguments: RunInTerminalRequestArguments;
808+
809+
/**
810+
* This property should only be set if the client has passed the value true
811+
* for the 'supportsArgsCanBeInterpretedByShell' capability of the
812+
* 'initialize' request. If the client uses an intermediary shell to launch
813+
* the application, then the client must not attempt to escape characters with
814+
* special meanings for the shell. The user is fully responsible for escaping
815+
* as needed and that arguments using special characters may not be portable
816+
* across shells.
817+
*/
818+
argsCanBeInterpretedByShell?: boolean;
804819
}
805820
```
806821

@@ -3341,6 +3356,12 @@ interface Capabilities {
33413356
* 'stepBack').
33423357
*/
33433358
supportsSingleThreadExecutionRequests?: boolean;
3359+
3360+
/**
3361+
* The debug adapter supports the 'argsCanBeInterpretedByShell' attribute on
3362+
* the 'runInTerminal' request.
3363+
*/
3364+
supportsArgsCanBeInterpretedByShell?: boolean;
33443365
}
33453366
```
33463367

0 commit comments

Comments
 (0)