Repository: vscode
Issue: Printenv in shellIntegration-bash.sh cause hang in terminal git bash
Labels: important


Type: <b>Performance Issue</b>

When i open one terminal with git bash in windows the windows hang for 20/30 second before open totally. After the openig i see the last output of printenv before the prompt.

The row that cause this are in the file shellIntegration-bash.sh, in the function __vsc_update_env . If i delete delete this function and the two call to __vsc_update_env() i dont have any problem anymore.

__vsc_update_env() {
	builtin printf '\e]633;EnvSingleStart;%s;\a' $__vsc_nonce
	for var in $(compgen -v); do
		if printenv "$var" >/dev/null 2>&1; then
			value=$(builtin printf '%s' "${!var}")
			builtin printf '\e]633;EnvSingleEntry;%s;%s;%s\a' "$var" "$(__vsc_escape_value "$value")" $__vsc_nonce
		fi
	done
	builtin printf '\e]633;EnvSingleEnd;%s;\a' $__vsc_nonce
}


VS Code version: Code - Insiders 1.97.0-insider (d226a2a497b928d78aa654f74c8af5317d3becfb, 2025-01-22T05:05:14.565Z)
OS version: Windows_NT x64 10.0.19045
Modes:

<details>
<summary>System Info</summary>

|Item|Value|
|---|---|
|CPUs|Intel(R) Xeon(R) CPU E5-2620 v4 @ 2.10GHz (32 x 2095)|
|GPU Status|2d_canvas: enabled<br>canvas_oop_rasterization: enabled_on<br>direct_rendering_display_compositor: disabled_off_ok<br>gpu_compositing: enabled<br>multiple_raster_threads: enabled_on<br>opengl: enabled_on<br>rasterization: enabled<br>raw_draw: disabled_off_ok<br>skia_graphite: disabled_off<br>video_decode: enabled<br>video_encode: enabled<br>vulkan: disabled_off<br>webgl: enabled<br>webgl2: enabled<br>webgpu: enabled<br>webnn: disabled_off|
|Load (avg)|undefined|
|Memory (System)|31.92GB (22.24GB free)|
|Process Argv|--crash-reporter-id cd6f428f-b0f8-40ce-8258-3cb7753136da|
|Screen Reader|no|
|VM|0%|
</details><details>
<summary>Process Info</summary>

```
CPU %	Mem MB	   PID	Process
    0	   133	 17420	code-insiders main
    0	    98	  3756	   gpu-process
    0	    30	  9088	   crashpad-handler
    0	   106	 11568	ptyHost
    0	     7	 13544	     conpty-agent
    0	     6	 24928	     "C:\Program Files\Git\bin\bash.exe" --init-file "c:\SoftwareLight\VS Code Insiders\resources\app/out/vs/workbench/contrib/terminal/common/scripts/shellIntegration-bash.sh"
    0	    12	  3704	       "C:\Program Files\Git\bin\..\usr\bin\bash.exe" --init-file "c:\SoftwareLight\VS Code Insiders\resources\app/out/vs/workbench/contrib/terminal/common/scripts/shellIntegration-bash.sh"
    0	   124	 16500	shared-process
    0	   150	 18544	extensionHost [1]
    0	   100	 11356	     "C:\SoftwareLight\VS Code Insiders\Code - Insiders.exe" "c:\SoftwareLight\VS Code Insiders\resources\app\extensions\json-language-features\server\dist\node\jsonServerMain" --node-ipc --clientProcessId=18544
    0	    46	 19632	   utility-network-service
    0	    99	 20728	fileWatcher [1]
    0	   225	 22436	window [1] (settings.json - gui-nmf (Workspace) - Visual Studio Code - Insiders)
```

</details>
<details>
<summary>Workspace Info</summary>

```
|  Window (settings.json - gui-nmf (Workspace) - Visual Studio Code - Insiders)
|    Folder (gui-proxy.nmf): 450 files
|      File types: js(129) map(57) css(50) html(50) scss(34) json(17) png(7)
|                  woff(7) woff2(5) svg(5)
|      Conf files: dockerfile(2) package.json(1)
|    Folder (gui-ansible.nmf): 76 files
|      File types: yml(26) j2(13) crt(6) cer(2) key(2) md(2) cfg(1) sh(1)
|      Conf files:
|    Folder (gui.nmf): 556 files
|      File types: scss(177) vue(118) js(82) css(40) json(6) png(5) svg(5)
|                  woff(4) woff2(3) md(2)
|      Conf files: dockerfile(1) package.json(1);
```

</details>
<details><summary>Extensions (9)</summary>

Extension|Author (truncated)|Version
---|---|---
vscode-html-css|ecm|2.0.12
beautify|Hoo|1.5.0
rest-client|hum|0.25.1
kubernetes-yaml-formatter|ken|2.4.0
vscode-docker|ms-|1.29.4
vscode-language-pack-it|MS-|1.97.2025012209
vetur|oct|0.37.3
uridecode|sry|0.3.6
JavaScriptSnippets|xab|1.8.0


</details><details>
<summary>A/B Experiments</summary>

```
vsliv368:30146709
vspor879:30202332
vspor708:30202333
vspor363:30204092
vsc_aacf:30263846
vscod805cf:30301675
vsaa593cf:30376535
py29gd2263:31024238
c4g48928:30535728
962ge761:30841072
pythonnoceb:30776497
dsvsc014:30777825
dsvsc015:30821418
pythonmypyd1:30859725
h48ei257:31000450
pythontbext0:30879054
cppperfnew:30980852
pythonait:30973460
dvdeprecation:31040973
dwnewjupyter:31046869
2f103344:31071589
nativerepl1:31134653
pythonrstrctxt:31093868
nativeloc1:31118317
cf971741:31144450
e80f6927:31120813
iacca1:31150324
notype1:31143044
dwcopilot:31158714
h409b430:31177054
5b1c1929:31184661
6074i472:31201624
dwoutputs:31217127
6e63a538:31218797
9064b325:31222308
copilot_t_ci:31222730

```

</details>

<!-- generated by issue reporter -->