From 2e26aa91cfec1975e06280c2fcfa91f0d8c7d949 Mon Sep 17 00:00:00 2001 From: "Z. Grace Moreau" Date: Tue, 9 Aug 2022 10:31:39 -0600 Subject: [PATCH] escape the commandline given to `633 E` Per the changes in #157571. --- .../terminal/browser/media/shellIntegration.fish | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/vs/workbench/contrib/terminal/browser/media/shellIntegration.fish b/src/vs/workbench/contrib/terminal/browser/media/shellIntegration.fish index 9aa556052ce..d3eb8d69432 100644 --- a/src/vs/workbench/contrib/terminal/browser/media/shellIntegration.fish +++ b/src/vs/workbench/contrib/terminal/browser/media/shellIntegration.fish @@ -33,7 +33,18 @@ end # Marks the beginning of command output. function __vsc_cmd_executed --on-event fish_preexec __vsc_esc C - __vsc_esc E "$argv" + __vsc_esc E (__vsc_escape_cmd "$argv") +end + + +# Escapes backslashes, newlines, and semicolons to serialize the command line. +function __vsc_escape_cmd + set -l commandline "$argv" + # `string replace` automatically breaks its input apart on any newlines. + # Then `string join` at the end will bring it all back together. + string replace --all '\\' '\\\\' $commandline \ + | string replace --all ';' '\x3b' \ + | string join '\x0a' end # Sent right after an interactive command has finished executing.