Skip to content

Commit

Permalink
A followup to microsoft#171066 fixing zsh and fish shells implementat…
Browse files Browse the repository at this point in the history
…ions

microsoft#171066 introduced a fix for applying PATH prefix on macOS login shells that resolved microsoft#99878. However it had little issues for each shell implementation.
This PR contains the following fixes:

`bash` fix:
 - Add missing `:` separator in the path setter to avoid path corruption
 - Add missing quotes to avoid path interpretation

`zsh` fix:
 - Add missing `:` separator in the path setter to avoid path corruption
 - Add missing quotes to avoid path interpretation
 - Move patching outside of `.zprofile` check as clean macOS install doesn't include this file, nevertheless PATH patching should still happen

 `fish` fix:
 - use `set -gx PATH` instead of `fish_add_path` as the latter has no effect on updating the path if entries already exist in it. Which is the case for some extensions, like [`vscode-micromamba`](https://github.com/mamba-org/vscode-micromamba) which modify process environment and after login shell rc processing path entries end up in the end.
  • Loading branch information
anton-matosov committed Jul 23, 2024
1 parent 22e3447 commit 4cbdf3f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ set --global VSCODE_SHELL_INTEGRATION 1

# Apply any explicit path prefix (see #99878)
if status --is-login; and set -q VSCODE_PATH_PREFIX
fish_add_path -p $VSCODE_PATH_PREFIX
set -gx PATH "$VSCODE_PATH_PREFIX:$PATH"
end
set -e VSCODE_PATH_PREFIX

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ if [ "$VSCODE_INJECTION" == "1" ]; then

# Apply any explicit path prefix (see #99878)
if [ -n "${VSCODE_PATH_PREFIX:-}" ]; then
export PATH=$VSCODE_PATH_PREFIX$PATH
export PATH="$VSCODE_PATH_PREFIX:$PATH"
builtin unset VSCODE_PATH_PREFIX
fi
fi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# ---------------------------------------------------------------------------------------------
if [[ $options[norcs] = off && -o "login" && -f $USER_ZDOTDIR/.zprofile ]]; then
VSCODE_ZDOTDIR=$ZDOTDIR
ZDOTDIR=$USER_ZDOTDIR
. $USER_ZDOTDIR/.zprofile
ZDOTDIR=$VSCODE_ZDOTDIR
if [[ $options[norcs] = off && -o "login" ]]; then
if [[ -f $USER_ZDOTDIR/.zprofile ]]; then
VSCODE_ZDOTDIR=$ZDOTDIR
ZDOTDIR=$USER_ZDOTDIR
. $USER_ZDOTDIR/.zprofile
ZDOTDIR=$VSCODE_ZDOTDIR
fi

# Apply any explicit path prefix (see #99878)
if (( ${+VSCODE_PATH_PREFIX} )); then
export PATH=$VSCODE_PATH_PREFIX$PATH
export PATH="$VSCODE_PATH_PREFIX:$PATH"
fi
builtin unset VSCODE_PATH_PREFIX
fi

0 comments on commit 4cbdf3f

Please sign in to comment.