-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
Conversation
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.
LGTM
// export enum EnvironmentVariableMutatorTiming { | ||
// AtSpawn = 1, | ||
// AfterShellIntegration = 2 | ||
// // TODO: Do we need a both? |
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.
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.
Just noticed
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 comment
The reason will be displayed to describe this comment to others. Learn more.
Should be VSCODE_ENV_PREPEND
instead
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.
Thanks 👍
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.
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 comment
The reason will be displayed to describe this comment to others. Learn more.
Should be VSCODE_ENV_APPEND
instead
Part of #179476
This implements the shell script part of #179476. With this, an extension can temporarily set the following variables via the
EnvironmentVariableCollection
to get this behavior, all of which have the formatvar1=value1:var2=value2
VSCODE_ENV_REPLACE
: Replace the variableVSCODE_ENV_PREPEND
: Add the value to the start of the variableVSCODE_ENV_APPEND
: Add the value to the end of the variableI'll be out for a few weeks so this is an MVP for the Python extension to use it. Eventually, when the API is added, we'll prevent it from working like this be sanitizing out any
VSCODE_ENV_*
variables when applying the environment variable collection to the process as we want VS Code core to have full control over them.