Skip to content
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

Merged
merged 9 commits into from Apr 7, 2023

Conversation

Tyriar
Copy link
Member

@Tyriar Tyriar commented Apr 7, 2023

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 format var1=value1:var2=value2

  • VSCODE_ENV_REPLACE: Replace the variable
  • VSCODE_ENV_PREPEND: Add the value to the start of the variable
  • VSCODE_ENV_APPEND: Add the value to the end of the variable

I'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.

@Tyriar Tyriar added this to the April 2023 milestone Apr 7, 2023
@Tyriar Tyriar self-assigned this Apr 7, 2023
@Tyriar Tyriar marked this pull request as ready for review April 7, 2023 16:53
Copy link
Contributor

@karrtikr karrtikr left a 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?
Copy link
Contributor

@karrtikr karrtikr Apr 7, 2023

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.

@Tyriar Tyriar merged commit a7755de into main Apr 7, 2023
6 of 7 checks passed
@Tyriar Tyriar deleted the tyriar/apply_si branch April 7, 2023 19:07
Copy link
Contributor

@karrtikr karrtikr left a 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
Copy link
Contributor

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks 👍

Copy link
Member Author

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
Copy link
Contributor

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

Tyriar added a commit that referenced this pull request Apr 7, 2023
@github-actions github-actions bot locked and limited conversation to collaborators May 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants