-
Notifications
You must be signed in to change notification settings - Fork 29.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support VSCODE_ENV_* variables to adjust environment in shell integration scripts #179472
Changes from all commits
7533d57
0096d5c
bb064ed
d1c4377
8c32630
0939143
e9ee55f
82582ac
0c85162
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,6 +45,35 @@ if [ -z "$VSCODE_SHELL_INTEGRATION" ]; then | |
builtin return | ||
fi | ||
|
||
# Apply EnvironmentVariableCollections if needed | ||
if [ -n "$VSCODE_ENV_REPLACE" ]; then | ||
IFS=':' read -ra ADDR <<< "$VSCODE_ENV_REPLACE" | ||
for ITEM in "${ADDR[@]}"; do | ||
VARNAME="$(echo $ITEM | cut -d "=" -f 1)" | ||
VALUE="$(echo $ITEM | cut -d "=" -f 2)" | ||
export $VARNAME="$VALUE" | ||
done | ||
builtin unset VSCODE_ENV_REPLACE | ||
fi | ||
if [ -n "$VSCODE_ENV_PREPEND" ]; then | ||
IFS=':' read -ra ADDR <<< "$VSCODE_ENV_PREPEND" | ||
for ITEM in "${ADDR[@]}"; do | ||
VARNAME="$(echo $ITEM | cut -d "=" -f 1)" | ||
VALUE="$(echo $ITEM | cut -d "=" -f 2)" | ||
export $VARNAME="$VALUE${!VARNAME}" | ||
done | ||
builtin unset VSCODE_ENV_REPLACE | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks 👍 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
fi | ||
if [ -n "$VSCODE_ENV_APPEND" ]; then | ||
IFS=':' read -ra ADDR <<< "$VSCODE_ENV_APPEND" | ||
for ITEM in "${ADDR[@]}"; do | ||
VARNAME="$(echo $ITEM | cut -d "=" -f 1)" | ||
VALUE="$(echo $ITEM | cut -d "=" -f 2)" | ||
export $VARNAME="${!VARNAME}$VALUE" | ||
done | ||
builtin unset VSCODE_ENV_REPLACE | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be |
||
fi | ||
|
||
__vsc_get_trap() { | ||
# 'trap -p DEBUG' outputs a shell command like `trap -- '…shellcode…' DEBUG`. | ||
# The terms are quoted literals, but are not guaranteed to be on a single line. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We likely need both as shell integration is not guaranteed to activate.