Properly load environment variables from the login shell (#31799)
Fixes #11647 Fixes #13888 Fixes #18771 Fixes #19779 Fixes #22437 Fixes #23649 Fixes #24200 Fixes #27601 Zed’s current method of loading environment variables from the login shell has two issues: 1. Some shells—fish in particular—write specific escape characters to `stdout` right before they exit. When this happens, the tail end of the last environment variable printed by `/usr/bin/env` becomes corrupted. 2. If a multi-line value contains an equals sign, that line is mis-parsed as a separate name-value pair. This PR addresses those problems by: 1. Redirecting the shell command's `stdout` directly to a temporary file, eliminating any side effects caused by the shell itself. 2. Replacing `/usr/bin/env` with `sh -c 'export -p'`, which removes ambiguity when handling multi-line values. Additional changes: - Correctly set the arguments used to launch a login shell under `csh` or `tcsh`. - Deduplicate code by sharing the implementation that loads environment variables on first run with the logic that reloads them for a project. Release Notes: - N/A
This commit is contained in:
parent
8227c45a11
commit
55120c4231
5 changed files with 303 additions and 150 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -17129,6 +17129,7 @@ dependencies = [
|
|||
"futures-lite 1.13.0",
|
||||
"git2",
|
||||
"globset",
|
||||
"indoc",
|
||||
"itertools 0.14.0",
|
||||
"libc",
|
||||
"log",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue