From d8f1111c6c69e8345061e783f93dd24df9a57a08 Mon Sep 17 00:00:00 2001 From: Anthony Kim Date: Wed, 15 Jan 2025 12:23:11 -0500 Subject: [PATCH 01/16] expose env for zsh + test --- .../terminal.shellIntegration.test.ts | 19 +++++++++++++++++-- .../common/scripts/shellIntegration-rc.zsh | 15 +++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/extensions/vscode-api-tests/src/singlefolder-tests/terminal.shellIntegration.test.ts b/extensions/vscode-api-tests/src/singlefolder-tests/terminal.shellIntegration.test.ts index 8f094091f962d..e644b0cf8824f 100644 --- a/extensions/vscode-api-tests/src/singlefolder-tests/terminal.shellIntegration.test.ts +++ b/extensions/vscode-api-tests/src/singlefolder-tests/terminal.shellIntegration.test.ts @@ -30,7 +30,7 @@ import { assertNoRpc } from '../utils'; disposables.length = 0; }); - function createTerminalAndWaitForShellIntegration(): Promise<{ terminal: Terminal; shellIntegration: TerminalShellIntegration }> { + function createTerminalAndWaitForShellIntegration(shellPath?: string): Promise<{ terminal: Terminal; shellIntegration: TerminalShellIntegration }> { return new Promise<{ terminal: Terminal; shellIntegration: TerminalShellIntegration }>(resolve => { disposables.push(window.onDidChangeTerminalShellIntegration(e => { if (e.terminal === terminal) { @@ -42,7 +42,7 @@ import { assertNoRpc } from '../utils'; })); const terminal = platform() === 'win32' ? window.createTerminal() - : window.createTerminal({ shellPath: '/bin/bash' }); + : window.createTerminal({ shellPath: shellPath ?? '/bin/bash' }); terminal.show(); }); } @@ -102,8 +102,23 @@ import { assertNoRpc } from '../utils'; ok(shellIntegration.env.PATH); ok(shellIntegration.env.PATH.length > 0, 'env.PATH should have a length greater than 0'); }); + + test.skip('Test if zsh env is set', async () => { + const { shellIntegration } = await createTerminalAndWaitForShellIntegration('/bin/zsh'); + await new Promise(r => { + disposables.push(window.onDidChangeTerminalShellIntegration(e => { + if (e.shellIntegration.env) { + r(); + } + })); + }); + ok(shellIntegration.env); + ok(shellIntegration.env.PATH); + ok(shellIntegration.env.PATH.length > 0, 'env.PATH should have a length greater than 0'); + }); } + test('execution events should fire in order when a command runs', async () => { const { terminal, shellIntegration } = await createTerminalAndWaitForShellIntegration(); const events: string[] = []; diff --git a/src/vs/workbench/contrib/terminal/common/scripts/shellIntegration-rc.zsh b/src/vs/workbench/contrib/terminal/common/scripts/shellIntegration-rc.zsh index 54a13d575f164..9e85f892b28c0 100644 --- a/src/vs/workbench/contrib/terminal/common/scripts/shellIntegration-rc.zsh +++ b/src/vs/workbench/contrib/terminal/common/scripts/shellIntegration-rc.zsh @@ -111,6 +111,17 @@ __vsc_update_cwd() { builtin printf '\e]633;P;Cwd=%s\a' "$(__vsc_escape_value "${PWD}")" } +__vsc_update_env() { + builtin printf '\e]633;EnvStart;%s;\a' $__vsc_nonce + for var in ${(k)parameters}; do + if printenv "$var" >/dev/null 2>&1; then + value=$(builtin printf '%s' "${(P)var}") + builtin printf '\e]633;EnvEntry;%s;%s;%s\a' "$var" "$(__vsc_escape_value "$value")" $__vsc_nonce + fi + done + builtin printf '\e]633;EnvEnd;%s;\a' $__vsc_nonce +} + __vsc_command_output_start() { builtin printf '\e]633;E;%s;%s\a' "$(__vsc_escape_value "${__vsc_current_command}")" $__vsc_nonce builtin printf '\e]633;C\a' @@ -139,6 +150,8 @@ __vsc_command_complete() { builtin printf '\e]633;D;%s\a' "$__vsc_status" fi __vsc_update_cwd + # Is there stable/insider flag in zsh? + __vsc_update_env } if [[ -o NOUNSET ]]; then @@ -173,6 +186,8 @@ __vsc_precmd() { # non null __vsc_update_prompt fi + # TODO: Is there stable/insider flag in zsh? + __vsc_update_env } __vsc_preexec() { From 2dff698dfbb5d747c086848a366a3bf629d2e5f1 Mon Sep 17 00:00:00 2001 From: Anthony Kim Date: Thu, 16 Jan 2025 10:37:02 -0500 Subject: [PATCH 02/16] pass in shellPath for when platform() is win32 too --- .../src/singlefolder-tests/terminal.shellIntegration.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/vscode-api-tests/src/singlefolder-tests/terminal.shellIntegration.test.ts b/extensions/vscode-api-tests/src/singlefolder-tests/terminal.shellIntegration.test.ts index e644b0cf8824f..86fc52cf66537 100644 --- a/extensions/vscode-api-tests/src/singlefolder-tests/terminal.shellIntegration.test.ts +++ b/extensions/vscode-api-tests/src/singlefolder-tests/terminal.shellIntegration.test.ts @@ -41,7 +41,7 @@ import { assertNoRpc } from '../utils'; } })); const terminal = platform() === 'win32' - ? window.createTerminal() + ? window.createTerminal({ shellPath }) : window.createTerminal({ shellPath: shellPath ?? '/bin/bash' }); terminal.show(); }); From 81880711959321280ed8c228cf07e50ca46fa48c Mon Sep 17 00:00:00 2001 From: Anthony Kim Date: Thu, 16 Jan 2025 10:47:20 -0500 Subject: [PATCH 03/16] get $__vsc_stable flag from terminalEnvironment.ts --- .../terminal/node/terminalEnvironment.ts | 1 + .../common/scripts/shellIntegration-rc.zsh | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/vs/platform/terminal/node/terminalEnvironment.ts b/src/vs/platform/terminal/node/terminalEnvironment.ts index 3688900dc2bc8..71398d253731b 100644 --- a/src/vs/platform/terminal/node/terminalEnvironment.ts +++ b/src/vs/platform/terminal/node/terminalEnvironment.ts @@ -224,6 +224,7 @@ export function getShellIntegrationInjection( source: path.join(appRoot, 'out/vs/workbench/contrib/terminal/common/scripts/shellIntegration-login.zsh'), dest: path.join(zdotdir, '.zlogin') }); + envMixin['VSCODE_STABLE'] = productService.quality === 'stable' ? '1' : '0'; return { newArgs, envMixin, filesToCopy }; } } diff --git a/src/vs/workbench/contrib/terminal/common/scripts/shellIntegration-rc.zsh b/src/vs/workbench/contrib/terminal/common/scripts/shellIntegration-rc.zsh index 9e85f892b28c0..31885e5179526 100644 --- a/src/vs/workbench/contrib/terminal/common/scripts/shellIntegration-rc.zsh +++ b/src/vs/workbench/contrib/terminal/common/scripts/shellIntegration-rc.zsh @@ -99,6 +99,10 @@ __vsc_current_command="" __vsc_nonce="$VSCODE_NONCE" unset VSCODE_NONCE +# Some features should only work in Insiders +__vsc_stable="$VSCODE_STABLE" +unset VSCODE_STABLE + __vsc_prompt_start() { builtin printf '\e]633;A\a' } @@ -150,8 +154,10 @@ __vsc_command_complete() { builtin printf '\e]633;D;%s\a' "$__vsc_status" fi __vsc_update_cwd - # Is there stable/insider flag in zsh? - __vsc_update_env + + if [[ "$__vsc_stable" == "0" ]]; then + __vsc_update_env + fi } if [[ -o NOUNSET ]]; then @@ -186,8 +192,10 @@ __vsc_precmd() { # non null __vsc_update_prompt fi - # TODO: Is there stable/insider flag in zsh? - __vsc_update_env + + if [[ "$__vsc_stable" == "0" ]]; then + __vsc_update_env + fi } __vsc_preexec() { From 2718b079efb4aa5754e413d6a777dab33f176e2a Mon Sep 17 00:00:00 2001 From: Anthony Kim Date: Thu, 16 Jan 2025 12:50:00 -0500 Subject: [PATCH 04/16] try not using stable flag just in zsh. Leave it in for .ts --- .../terminal/common/scripts/shellIntegration-rc.zsh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/vs/workbench/contrib/terminal/common/scripts/shellIntegration-rc.zsh b/src/vs/workbench/contrib/terminal/common/scripts/shellIntegration-rc.zsh index 31885e5179526..131e8afecb223 100644 --- a/src/vs/workbench/contrib/terminal/common/scripts/shellIntegration-rc.zsh +++ b/src/vs/workbench/contrib/terminal/common/scripts/shellIntegration-rc.zsh @@ -155,9 +155,9 @@ __vsc_command_complete() { fi __vsc_update_cwd - if [[ "$__vsc_stable" == "0" ]]; then - __vsc_update_env - fi + # if [[ "$__vsc_stable" == "0" ]]; then + __vsc_update_env + # fi } if [[ -o NOUNSET ]]; then @@ -193,9 +193,9 @@ __vsc_precmd() { __vsc_update_prompt fi - if [[ "$__vsc_stable" == "0" ]]; then - __vsc_update_env - fi + # if [[ "$__vsc_stable" == "0" ]]; then + __vsc_update_env + # fi } __vsc_preexec() { From 0a8a8b416b6f5acdd6442b75d7eb24529bd7e15d Mon Sep 17 00:00:00 2001 From: Anthony Kim Date: Thu, 16 Jan 2025 13:19:47 -0500 Subject: [PATCH 05/16] comment out envMixin VSCODE_STABLE --- src/vs/platform/terminal/node/terminalEnvironment.ts | 2 +- .../contrib/terminal/common/scripts/shellIntegration-rc.zsh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/vs/platform/terminal/node/terminalEnvironment.ts b/src/vs/platform/terminal/node/terminalEnvironment.ts index 71398d253731b..d89d8c9277d2f 100644 --- a/src/vs/platform/terminal/node/terminalEnvironment.ts +++ b/src/vs/platform/terminal/node/terminalEnvironment.ts @@ -224,7 +224,7 @@ export function getShellIntegrationInjection( source: path.join(appRoot, 'out/vs/workbench/contrib/terminal/common/scripts/shellIntegration-login.zsh'), dest: path.join(zdotdir, '.zlogin') }); - envMixin['VSCODE_STABLE'] = productService.quality === 'stable' ? '1' : '0'; + // envMixin['VSCODE_STABLE'] = productService.quality === 'stable' ? '1' : '0'; return { newArgs, envMixin, filesToCopy }; } } diff --git a/src/vs/workbench/contrib/terminal/common/scripts/shellIntegration-rc.zsh b/src/vs/workbench/contrib/terminal/common/scripts/shellIntegration-rc.zsh index 131e8afecb223..51f3a45d96220 100644 --- a/src/vs/workbench/contrib/terminal/common/scripts/shellIntegration-rc.zsh +++ b/src/vs/workbench/contrib/terminal/common/scripts/shellIntegration-rc.zsh @@ -100,8 +100,8 @@ __vsc_nonce="$VSCODE_NONCE" unset VSCODE_NONCE # Some features should only work in Insiders -__vsc_stable="$VSCODE_STABLE" -unset VSCODE_STABLE +# __vsc_stable="$VSCODE_STABLE" +# unset VSCODE_STABLE __vsc_prompt_start() { builtin printf '\e]633;A\a' From 7b8757404e1227b55d2f902d7a1c0ae7258bd201 Mon Sep 17 00:00:00 2001 From: Anthony Kim Date: Thu, 16 Jan 2025 14:04:10 -0500 Subject: [PATCH 06/16] at least uncomment ts side --- src/vs/platform/terminal/node/terminalEnvironment.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vs/platform/terminal/node/terminalEnvironment.ts b/src/vs/platform/terminal/node/terminalEnvironment.ts index d89d8c9277d2f..71398d253731b 100644 --- a/src/vs/platform/terminal/node/terminalEnvironment.ts +++ b/src/vs/platform/terminal/node/terminalEnvironment.ts @@ -224,7 +224,7 @@ export function getShellIntegrationInjection( source: path.join(appRoot, 'out/vs/workbench/contrib/terminal/common/scripts/shellIntegration-login.zsh'), dest: path.join(zdotdir, '.zlogin') }); - // envMixin['VSCODE_STABLE'] = productService.quality === 'stable' ? '1' : '0'; + envMixin['VSCODE_STABLE'] = productService.quality === 'stable' ? '1' : '0'; return { newArgs, envMixin, filesToCopy }; } } From cb34f37e6032a7a542a2f54b46675ddbe1b17de8 Mon Sep 17 00:00:00 2001 From: Anthony Kim Date: Thu, 16 Jan 2025 15:46:03 -0500 Subject: [PATCH 07/16] is this real? --- src/vs/platform/terminal/test/node/terminalEnvironment.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vs/platform/terminal/test/node/terminalEnvironment.test.ts b/src/vs/platform/terminal/test/node/terminalEnvironment.test.ts index 6248f83003d4f..28c2072f0a15a 100644 --- a/src/vs/platform/terminal/test/node/terminalEnvironment.test.ts +++ b/src/vs/platform/terminal/test/node/terminalEnvironment.test.ts @@ -132,7 +132,7 @@ suite('platform - terminalEnvironment', () => { /.+\/out\/vs\/workbench\/contrib\/terminal\/common\/scripts\/shellIntegration-login.zsh/ ]; function assertIsEnabled(result: IShellIntegrationConfigInjection, globalZdotdir = homedir()) { - strictEqual(Object.keys(result.envMixin!).length, 3); + strictEqual(Object.keys(result.envMixin!).length, 4); ok(result.envMixin!['ZDOTDIR']?.match(expectedDir)); strictEqual(result.envMixin!['USER_ZDOTDIR'], globalZdotdir); ok(result.envMixin!['VSCODE_INJECTION']?.match('1')); From 30b45136b08164d88436cd58f395d34b787efc19 Mon Sep 17 00:00:00 2001 From: Anthony Kim Date: Thu, 16 Jan 2025 16:04:34 -0500 Subject: [PATCH 08/16] re-enable __vsc_stable --- .../test/node/terminalEnvironment.test.ts | 1 - .../common/scripts/shellIntegration-rc.zsh | 16 ++++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/vs/platform/terminal/test/node/terminalEnvironment.test.ts b/src/vs/platform/terminal/test/node/terminalEnvironment.test.ts index 28c2072f0a15a..0829f838db638 100644 --- a/src/vs/platform/terminal/test/node/terminalEnvironment.test.ts +++ b/src/vs/platform/terminal/test/node/terminalEnvironment.test.ts @@ -132,7 +132,6 @@ suite('platform - terminalEnvironment', () => { /.+\/out\/vs\/workbench\/contrib\/terminal\/common\/scripts\/shellIntegration-login.zsh/ ]; function assertIsEnabled(result: IShellIntegrationConfigInjection, globalZdotdir = homedir()) { - strictEqual(Object.keys(result.envMixin!).length, 4); ok(result.envMixin!['ZDOTDIR']?.match(expectedDir)); strictEqual(result.envMixin!['USER_ZDOTDIR'], globalZdotdir); ok(result.envMixin!['VSCODE_INJECTION']?.match('1')); diff --git a/src/vs/workbench/contrib/terminal/common/scripts/shellIntegration-rc.zsh b/src/vs/workbench/contrib/terminal/common/scripts/shellIntegration-rc.zsh index 51f3a45d96220..31885e5179526 100644 --- a/src/vs/workbench/contrib/terminal/common/scripts/shellIntegration-rc.zsh +++ b/src/vs/workbench/contrib/terminal/common/scripts/shellIntegration-rc.zsh @@ -100,8 +100,8 @@ __vsc_nonce="$VSCODE_NONCE" unset VSCODE_NONCE # Some features should only work in Insiders -# __vsc_stable="$VSCODE_STABLE" -# unset VSCODE_STABLE +__vsc_stable="$VSCODE_STABLE" +unset VSCODE_STABLE __vsc_prompt_start() { builtin printf '\e]633;A\a' @@ -155,9 +155,9 @@ __vsc_command_complete() { fi __vsc_update_cwd - # if [[ "$__vsc_stable" == "0" ]]; then - __vsc_update_env - # fi + if [[ "$__vsc_stable" == "0" ]]; then + __vsc_update_env + fi } if [[ -o NOUNSET ]]; then @@ -193,9 +193,9 @@ __vsc_precmd() { __vsc_update_prompt fi - # if [[ "$__vsc_stable" == "0" ]]; then - __vsc_update_env - # fi + if [[ "$__vsc_stable" == "0" ]]; then + __vsc_update_env + fi } __vsc_preexec() { From e3c12a8c2bf2d53ac51fe3a61031c1e1b3d4313e Mon Sep 17 00:00:00 2001 From: Anthony Kim Date: Fri, 17 Jan 2025 01:24:25 -0500 Subject: [PATCH 09/16] handle edge case, from more rigorous testing --- .../terminal/common/scripts/shellIntegration-rc.zsh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/vs/workbench/contrib/terminal/common/scripts/shellIntegration-rc.zsh b/src/vs/workbench/contrib/terminal/common/scripts/shellIntegration-rc.zsh index 31885e5179526..089474c2849c3 100644 --- a/src/vs/workbench/contrib/terminal/common/scripts/shellIntegration-rc.zsh +++ b/src/vs/workbench/contrib/terminal/common/scripts/shellIntegration-rc.zsh @@ -116,14 +116,19 @@ __vsc_update_cwd() { } __vsc_update_env() { - builtin printf '\e]633;EnvStart;%s;\a' $__vsc_nonce + builtin printf '\e]633;EnvSingleStart;%s;\a' $__vsc_nonce for var in ${(k)parameters}; do if printenv "$var" >/dev/null 2>&1; then value=$(builtin printf '%s' "${(P)var}") - builtin printf '\e]633;EnvEntry;%s;%s;%s\a' "$var" "$(__vsc_escape_value "$value")" $__vsc_nonce + # Skip variables with values that start with a hypen + # Things like -q can lead to __vsc_escape_value bad option + if [[ "$value" == -* ]]; then + continue + fi + builtin printf '\e]633;EnvSingleEntry;%s;%s;%s\a' "$var" "$(__vsc_escape_value "$value")" $__vsc_nonce fi done - builtin printf '\e]633;EnvEnd;%s;\a' $__vsc_nonce + builtin printf '\e]633;EnvSingleEnd;%s;\a' $__vsc_nonce } __vsc_command_output_start() { From 6a6cfadea2c2cc7c2e960b13139eea0dc409fbfc Mon Sep 17 00:00:00 2001 From: Anthony Kim Date: Fri, 17 Jan 2025 01:29:03 -0500 Subject: [PATCH 10/16] also skip when variable starts with hypen --- .../contrib/terminal/common/scripts/shellIntegration-rc.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vs/workbench/contrib/terminal/common/scripts/shellIntegration-rc.zsh b/src/vs/workbench/contrib/terminal/common/scripts/shellIntegration-rc.zsh index 089474c2849c3..013aef5dedf1d 100644 --- a/src/vs/workbench/contrib/terminal/common/scripts/shellIntegration-rc.zsh +++ b/src/vs/workbench/contrib/terminal/common/scripts/shellIntegration-rc.zsh @@ -122,7 +122,7 @@ __vsc_update_env() { value=$(builtin printf '%s' "${(P)var}") # Skip variables with values that start with a hypen # Things like -q can lead to __vsc_escape_value bad option - if [[ "$value" == -* ]]; then + if [[ "$value" == -* || "$var" == -* ]]; then continue fi builtin printf '\e]633;EnvSingleEntry;%s;%s;%s\a' "$var" "$(__vsc_escape_value "$value")" $__vsc_nonce From 9013dde56de0ded5e8b6387a0a0e63615efce2d6 Mon Sep 17 00:00:00 2001 From: Anthony Kim Date: Fri, 17 Jan 2025 01:31:21 -0500 Subject: [PATCH 11/16] handle edge case better with hypens --- .../contrib/terminal/common/scripts/shellIntegration-rc.zsh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/vs/workbench/contrib/terminal/common/scripts/shellIntegration-rc.zsh b/src/vs/workbench/contrib/terminal/common/scripts/shellIntegration-rc.zsh index 013aef5dedf1d..737eca2804a76 100644 --- a/src/vs/workbench/contrib/terminal/common/scripts/shellIntegration-rc.zsh +++ b/src/vs/workbench/contrib/terminal/common/scripts/shellIntegration-rc.zsh @@ -120,9 +120,9 @@ __vsc_update_env() { for var in ${(k)parameters}; do if printenv "$var" >/dev/null 2>&1; then value=$(builtin printf '%s' "${(P)var}") - # Skip variables with values that start with a hypen - # Things like -q can lead to __vsc_escape_value bad option - if [[ "$value" == -* || "$var" == -* ]]; then + # It is not valid to have hypen in variable name + # It is not valid to have hypen to start variable value + if [[ "$value" == -* || "$var" == *-* ]]; then continue fi builtin printf '\e]633;EnvSingleEntry;%s;%s;%s\a' "$var" "$(__vsc_escape_value "$value")" $__vsc_nonce From ab0a511b34b571096c0753e1fa3c9bfe4cc3ae83 Mon Sep 17 00:00:00 2001 From: Anthony Kim Date: Fri, 17 Jan 2025 01:48:38 -0500 Subject: [PATCH 12/16] remove extra line --- .../src/singlefolder-tests/terminal.shellIntegration.test.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/extensions/vscode-api-tests/src/singlefolder-tests/terminal.shellIntegration.test.ts b/extensions/vscode-api-tests/src/singlefolder-tests/terminal.shellIntegration.test.ts index 86fc52cf66537..291d3d354b5d3 100644 --- a/extensions/vscode-api-tests/src/singlefolder-tests/terminal.shellIntegration.test.ts +++ b/extensions/vscode-api-tests/src/singlefolder-tests/terminal.shellIntegration.test.ts @@ -118,7 +118,6 @@ import { assertNoRpc } from '../utils'; }); } - test('execution events should fire in order when a command runs', async () => { const { terminal, shellIntegration } = await createTerminalAndWaitForShellIntegration(); const events: string[] = []; From c919ff1f2cefaefe148acfaf4b657dd3602ac39c Mon Sep 17 00:00:00 2001 From: Anthony Kim Date: Fri, 17 Jan 2025 16:34:48 -0500 Subject: [PATCH 13/16] aim to better handle - in vsc_escape_value in hex, similar to other escapes --- .../terminal/common/scripts/shellIntegration-rc.zsh | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/vs/workbench/contrib/terminal/common/scripts/shellIntegration-rc.zsh b/src/vs/workbench/contrib/terminal/common/scripts/shellIntegration-rc.zsh index 737eca2804a76..75ab0ceb44d58 100644 --- a/src/vs/workbench/contrib/terminal/common/scripts/shellIntegration-rc.zsh +++ b/src/vs/workbench/contrib/terminal/common/scripts/shellIntegration-rc.zsh @@ -75,13 +75,15 @@ __vsc_escape_value() { for (( i = 0; i < ${#str}; ++i )); do byte="${str:$i:1}" - # Escape backslashes, semi-colons and newlines + # Escape backslashes, semi-colons, newlines, and hyphens. if [ "$byte" = "\\" ]; then token="\\\\" elif [ "$byte" = ";" ]; then token="\\x3b" elif [ "$byte" = $'\n' ]; then token="\x0a" + elif [ "$byte" = "-" ]; then + token="\\x2d" else token="$byte" fi @@ -120,11 +122,6 @@ __vsc_update_env() { for var in ${(k)parameters}; do if printenv "$var" >/dev/null 2>&1; then value=$(builtin printf '%s' "${(P)var}") - # It is not valid to have hypen in variable name - # It is not valid to have hypen to start variable value - if [[ "$value" == -* || "$var" == *-* ]]; then - continue - fi builtin printf '\e]633;EnvSingleEntry;%s;%s;%s\a' "$var" "$(__vsc_escape_value "$value")" $__vsc_nonce fi done From 6446430c4e458427120f57eed8e6e431826a41a6 Mon Sep 17 00:00:00 2001 From: Anthony Kim Date: Tue, 21 Jan 2025 14:52:18 -0500 Subject: [PATCH 14/16] use -- and remove special case for hypen --- .../contrib/terminal/common/scripts/shellIntegration-rc.zsh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/vs/workbench/contrib/terminal/common/scripts/shellIntegration-rc.zsh b/src/vs/workbench/contrib/terminal/common/scripts/shellIntegration-rc.zsh index 75ab0ceb44d58..efcf6ca860688 100644 --- a/src/vs/workbench/contrib/terminal/common/scripts/shellIntegration-rc.zsh +++ b/src/vs/workbench/contrib/terminal/common/scripts/shellIntegration-rc.zsh @@ -82,8 +82,6 @@ __vsc_escape_value() { token="\\x3b" elif [ "$byte" = $'\n' ]; then token="\x0a" - elif [ "$byte" = "-" ]; then - token="\\x2d" else token="$byte" fi @@ -91,7 +89,7 @@ __vsc_escape_value() { out+="$token" done - builtin print -r "$out" + builtin print -r -- "$out" } __vsc_in_command_execution="1" From 258261710a279b8e11548d88127e8e92c96b7bbf Mon Sep 17 00:00:00 2001 From: Anthony Kim Date: Tue, 21 Jan 2025 15:00:27 -0500 Subject: [PATCH 15/16] revert my comment on hypens --- .../contrib/terminal/common/scripts/shellIntegration-rc.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vs/workbench/contrib/terminal/common/scripts/shellIntegration-rc.zsh b/src/vs/workbench/contrib/terminal/common/scripts/shellIntegration-rc.zsh index efcf6ca860688..e9db9f42183c4 100644 --- a/src/vs/workbench/contrib/terminal/common/scripts/shellIntegration-rc.zsh +++ b/src/vs/workbench/contrib/terminal/common/scripts/shellIntegration-rc.zsh @@ -75,7 +75,7 @@ __vsc_escape_value() { for (( i = 0; i < ${#str}; ++i )); do byte="${str:$i:1}" - # Escape backslashes, semi-colons, newlines, and hyphens. + # Escape backslashes, semi-colons, newlines if [ "$byte" = "\\" ]; then token="\\\\" elif [ "$byte" = ";" ]; then From c30c5259c099c41d85a0d216ab07a5f12511fdde Mon Sep 17 00:00:00 2001 From: Anthony Kim Date: Tue, 21 Jan 2025 15:10:40 -0500 Subject: [PATCH 16/16] leave og --- .../contrib/terminal/common/scripts/shellIntegration-rc.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vs/workbench/contrib/terminal/common/scripts/shellIntegration-rc.zsh b/src/vs/workbench/contrib/terminal/common/scripts/shellIntegration-rc.zsh index e9db9f42183c4..6482665b969f1 100644 --- a/src/vs/workbench/contrib/terminal/common/scripts/shellIntegration-rc.zsh +++ b/src/vs/workbench/contrib/terminal/common/scripts/shellIntegration-rc.zsh @@ -75,7 +75,7 @@ __vsc_escape_value() { for (( i = 0; i < ${#str}; ++i )); do byte="${str:$i:1}" - # Escape backslashes, semi-colons, newlines + # Escape backslashes, semi-colons and newlines if [ "$byte" = "\\" ]; then token="\\\\" elif [ "$byte" = ";" ]; then