From 0ac5cce00886d3428490d60fc816c6aabadccd0c Mon Sep 17 00:00:00 2001 From: Megan Rogge Date: Tue, 21 Jan 2025 13:57:07 -0600 Subject: [PATCH] prevent `.zlogin` and `.zprofile` from running more than once (#238388) Fix #238296 --- .../terminal/common/scripts/shellIntegration-login.zsh | 6 ++++++ .../terminal/common/scripts/shellIntegration-profile.zsh | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/src/vs/workbench/contrib/terminal/common/scripts/shellIntegration-login.zsh b/src/vs/workbench/contrib/terminal/common/scripts/shellIntegration-login.zsh index 128bd648616..8edbca365e4 100644 --- a/src/vs/workbench/contrib/terminal/common/scripts/shellIntegration-login.zsh +++ b/src/vs/workbench/contrib/terminal/common/scripts/shellIntegration-login.zsh @@ -3,6 +3,12 @@ # Licensed under the MIT License. See License.txt in the project root for license information. # --------------------------------------------------------------------------------------------- +# Prevent recursive sourcing +if [[ -n "$VSCODE_LOGIN_INITIALIZED" ]]; then + return +fi +export VSCODE_LOGIN_INITIALIZED=1 + ZDOTDIR=$USER_ZDOTDIR if [[ $options[norcs] = off && -o "login" && -f $ZDOTDIR/.zlogin ]]; then . $ZDOTDIR/.zlogin diff --git a/src/vs/workbench/contrib/terminal/common/scripts/shellIntegration-profile.zsh b/src/vs/workbench/contrib/terminal/common/scripts/shellIntegration-profile.zsh index c25ded3d7eb..7401c10d376 100644 --- a/src/vs/workbench/contrib/terminal/common/scripts/shellIntegration-profile.zsh +++ b/src/vs/workbench/contrib/terminal/common/scripts/shellIntegration-profile.zsh @@ -2,6 +2,13 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. # --------------------------------------------------------------------------------------------- + +# Prevent recursive sourcing +if [[ -n "$VSCODE_PROFILE_INITIALIZED" ]]; then + return +fi +export VSCODE_PROFILE_INITIALIZED=1 + if [[ $options[norcs] = off && -o "login" ]]; then if [[ -f $USER_ZDOTDIR/.zprofile ]]; then VSCODE_ZDOTDIR=$ZDOTDIR