Skip to content

Commit f470910

Browse files
authored
Revert "Expose shell's environment - bash (#237602)"
This reverts commit e6805d7.
1 parent 3ff1dce commit f470910

File tree

5 files changed

+1
-106
lines changed

5 files changed

+1
-106
lines changed

extensions/vscode-api-tests/src/singlefolder-tests/terminal.shellIntegration.test.ts

-10
Original file line numberDiff line numberDiff line change
@@ -87,16 +87,6 @@ import { assertNoRpc } from '../utils';
8787
await closeTerminalAsync(terminal);
8888
});
8989

90-
if (platform() === 'darwin' || platform() === 'linux') {
91-
test('Test if env is set', async () => {
92-
const { shellIntegration } = await createTerminalAndWaitForShellIntegration();
93-
const env = shellIntegration.env;
94-
ok(env);
95-
ok(env.PATH);
96-
ok(env.PATH.length > 0, 'env.PATH should have a length greater than 0');
97-
});
98-
}
99-
10090
test('execution events should fire in order when a command runs', async () => {
10191
const { terminal, shellIntegration } = await createTerminalAndWaitForShellIntegration();
10292
const events: string[] = [];

src/vs/platform/terminal/common/capabilities/capabilities.ts

-3
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,6 @@ export interface IShellEnvDetectionCapability {
155155
readonly onDidChangeEnv: Event<Map<string, string>>;
156156
get env(): Map<string, string>;
157157
setEnvironment(envs: { [key: string]: string | undefined } | undefined, isTrusted: boolean): void;
158-
startEnvironmentSingleVar(isTrusted: boolean): void;
159-
setEnvironmentSingleVar(key: string, value: string | undefined, isTrusted: boolean): void;
160-
endEnvironmentSingleVar(isTrusted: boolean): void;
161158
}
162159

163160
export const enum CommandInvalidationReason {

src/vs/platform/terminal/common/capabilities/shellEnvDetectionCapability.ts

+1-28
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ import { equals } from '../../../../base/common/objects.js';
1111
export class ShellEnvDetectionCapability extends Disposable implements IShellEnvDetectionCapability {
1212
readonly type = TerminalCapability.ShellEnvDetection;
1313

14-
private _pendingEnv: Map<string, string> | undefined;
15-
private _env: Map<string, string> = new Map();
14+
private readonly _env: Map<string, string> = new Map();
1615
get env(): Map<string, string> { return this._env; }
1716

1817
private readonly _onDidChangeEnv = this._register(new Emitter<Map<string, string>>());
@@ -37,30 +36,4 @@ export class ShellEnvDetectionCapability extends Disposable implements IShellEnv
3736
// Convert to event and fire event
3837
this._onDidChangeEnv.fire(this._env);
3938
}
40-
41-
startEnvironmentSingleVar(isTrusted: boolean): void {
42-
if (!isTrusted) {
43-
return;
44-
}
45-
this._pendingEnv = new Map();
46-
}
47-
setEnvironmentSingleVar(key: string, value: string | undefined, isTrusted: boolean): void {
48-
if (!isTrusted) {
49-
return;
50-
}
51-
if (key !== undefined && value !== undefined) {
52-
this._pendingEnv?.set(key, value);
53-
}
54-
}
55-
endEnvironmentSingleVar(isTrusted: boolean): void {
56-
if (!isTrusted) {
57-
return;
58-
}
59-
if (!this._pendingEnv) {
60-
return;
61-
}
62-
this._env = this._pendingEnv;
63-
this._pendingEnv = undefined;
64-
this._onDidChangeEnv.fire(this._env);
65-
}
6639
}

src/vs/platform/terminal/common/xterm/shellIntegrationAddon.ts

-46
Original file line numberDiff line numberDiff line change
@@ -239,34 +239,6 @@ const enum VSCodeOscPt {
239239
*/
240240
EnvJson = 'EnvJson',
241241

242-
/**
243-
* The start of the collecting user's environment variables individually.
244-
* Clears any environment residuals in previous sessions.
245-
*
246-
* Format: `OSC 633 ; EnvSingleStart ; <Nonce>`
247-
*
248-
* WARNING: This sequence is unfinalized, DO NOT use this in your shell integration script.
249-
*/
250-
EnvSingleStart = 'EnvSingleStart',
251-
252-
/**
253-
* Sets an entry of single environment variable to transactional pending map of environment variables.
254-
*
255-
* Format: `OSC 633 ; EnvSingleEntry ; <EnvironmentKey> ; <EnvironmentValue> ; <Nonce>`
256-
*
257-
* WARNING: This sequence is unfinalized, DO NOT use this in your shell integration script.
258-
*/
259-
EnvSingleEntry = 'EnvSingleEntry',
260-
261-
/**
262-
* The end of the collecting user's environment variables individually.
263-
* Clears any pending environment variables and fires an event that contains user's environment.
264-
*
265-
* Format: `OSC 633 ; EnvSingleEnd ; <Nonce>`
266-
*
267-
* WARNING: This sequence is unfinalized, DO NOT use this in your shell integration script.
268-
*/
269-
EnvSingleEnd = 'EnvSingleEnd'
270242
}
271243

272244
/**
@@ -474,24 +446,6 @@ export class ShellIntegrationAddon extends Disposable implements IShellIntegrati
474446
}
475447
return true;
476448
}
477-
case VSCodeOscPt.EnvSingleStart: {
478-
this._createOrGetShellEnvDetection().startEnvironmentSingleVar(args[0] === this._nonce);
479-
return true;
480-
}
481-
case VSCodeOscPt.EnvSingleEntry: {
482-
const arg0 = args[0];
483-
const arg1 = args[1];
484-
const arg2 = args[2];
485-
if (arg0 !== undefined && arg1 !== undefined) {
486-
const env = deserializeMessage(arg1);
487-
this._createOrGetShellEnvDetection().setEnvironmentSingleVar(arg0, env, arg2 === this._nonce);
488-
}
489-
return true;
490-
}
491-
case VSCodeOscPt.EnvSingleEnd: {
492-
this._createOrGetShellEnvDetection().endEnvironmentSingleVar(args[0] === this._nonce);
493-
return true;
494-
}
495449
case VSCodeOscPt.RightPromptStart: {
496450
this._createOrGetCommandDetection(this._terminal).handleRightPromptStart();
497451
return true;

src/vs/workbench/contrib/terminal/common/scripts/shellIntegration-bash.sh

-19
Original file line numberDiff line numberDiff line change
@@ -214,17 +214,6 @@ __vsc_update_cwd() {
214214
builtin printf '\e]633;P;Cwd=%s\a' "$(__vsc_escape_value "$__vsc_cwd")"
215215
}
216216

217-
__vsc_update_env() {
218-
builtin printf '\e]633;EnvSingleStart;%s;\a' $__vsc_nonce
219-
for var in $(compgen -v); do
220-
if printenv "$var" >/dev/null 2>&1; then
221-
value=$(builtin printf '%s' "${!var}")
222-
builtin printf '\e]633;EnvSingleEntry;%s;%s;%s\a' "$var" "$(__vsc_escape_value "$value")" $__vsc_nonce
223-
fi
224-
done
225-
builtin printf '\e]633;EnvSingleEnd;%s;\a' $__vsc_nonce
226-
}
227-
228217
__vsc_command_output_start() {
229218
if [[ -z "${__vsc_first_prompt-}" ]]; then
230219
builtin return
@@ -251,10 +240,6 @@ __vsc_command_complete() {
251240
builtin printf '\e]633;D;%s\a' "$__vsc_status"
252241
fi
253242
__vsc_update_cwd
254-
255-
if [ "$__vsc_stable" = "0" ]; then
256-
__vsc_update_env
257-
fi
258243
}
259244
__vsc_update_prompt() {
260245
# in command execution
@@ -284,10 +269,6 @@ __vsc_precmd() {
284269
fi
285270
__vsc_first_prompt=1
286271
__vsc_update_prompt
287-
288-
if [ "$__vsc_stable" = "0" ]; then
289-
__vsc_update_env
290-
fi
291272
}
292273

293274
__vsc_preexec() {

0 commit comments

Comments
 (0)