Skip to content

Commit 0dbbd8b

Browse files
authored
only run in shell when on windows and running a .bat file (#252)
Based on this suggestion from @DanTup dart-lang/tools#2138 (comment)
1 parent 0858b0b commit 0dbbd8b

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

pkgs/dart_mcp/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
- The old `reject` enum value was replaced with a static constant equal
99
exactly to `decline`, so switches are not affected.
1010
- Add `title` parameter to `Prompt` constructor.
11+
- Only execute sub-processes in a shell if they are `.bat` files.
1112

1213
## 0.3.2
1314

pkgs/dart_mcp_server/lib/src/utils/cli_utils.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// BSD-style license that can be found in the LICENSE file.
44

55
import 'dart:async';
6+
import 'dart:io' as io;
67

78
import 'package:collection/collection.dart';
89
import 'package:dart_mcp/server.dart';
@@ -224,7 +225,10 @@ Future<CallToolResult> runCommandInRoot(
224225
final result = await processManager.run(
225226
commandWithPaths,
226227
workingDirectory: workingDir.path,
227-
runInShell: true,
228+
runInShell:
229+
// Required when running .bat files on windows, but otherwise should
230+
// be avoided due to escaping behavior.
231+
io.Platform.isWindows && commandWithPaths.first.endsWith('.bat'),
228232
);
229233

230234
final output = (result.stdout as String).trim();

0 commit comments

Comments
 (0)