Skip to content

Commit

Permalink
added quotes for Windows paths with spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexHaxe committed Oct 22, 2024
1 parent 887367d commit b085435
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/Main.hx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class Main extends vscode.debugAdapter.DebugSession {
final haxeArgs = args.args;
final cwd = args.cwd;

final haxe = args.haxeExecutable.executable;
final haxe = shellEscapeCommand(args.haxeExecutable.executable);

final env = new haxe.DynamicAccess();
for (key in js.Node.process.env.keys())
Expand Down Expand Up @@ -494,6 +494,17 @@ class Main extends vscode.debugAdapter.DebugSession {
sendResponse(response);
}

function shellEscapeCommand(command:String):String {
if (!~/[^a-zA-Z0-9_.:\/\\-]/.match(command)) {
return command;
}
if (command.startsWith('"') && command.endsWith('"')) {
return command;
}

return '"' + command.replace('"', '\\"') + '"';
}

static function main() {
vscode.debugAdapter.DebugSession.run(Main);
}
Expand Down

0 comments on commit b085435

Please sign in to comment.