rari404
cbe6eb2ab8
terminal: Remove SHLVL from terminal environment to fix incorrect shell level ( #44835 )
...
Fixes #33958
## Problem
When opening a terminal in Zed, `SHLVL` incorrectly starts at 2 instead
of 1. On `workspace: reload`, it increases by 2 instead of 1.
## Root Cause
1. Zed's `shell_env::capture()` spawns a login shell (`-l -i -c`) to
capture the user's environment, which increments `SHLVL`
2. The captured `SHLVL` is passed through to the PTY options
3. When alacritty_terminal spawns the user's shell, it increments
`SHLVL` again
Result: `SHLVL` = captured value + 1 = 2 (when launched from Finder)
## Solution
Remove `SHLVL` from the environment in `TerminalBuilder::new()` before
passing it to alacritty_terminal. This allows the spawned shell to
initialize `SHLVL` to 1 on its own, matching the behavior of standalone
terminal emulators like iTerm2, Kitty, and Alacritty.
## Testing
- Launch Zed from Finder → open terminal → `echo $SHLVL` → should output
`1`
- Launch Zed from shell → open terminal → `echo $SHLVL` → should output
`1`
- `workspace: reload` → open terminal → `echo $SHLVL` → should remain
`1`
- Tested with bash, zsh, fish
Release Notes:
- Fixed terminal `$SHLVL` starting at 2 instead of 1
([#33958 ](https://github.com/zed-industries/zed/issues/33958 ))
2025-12-15 08:12:24 +01:00
..
2025-12-15 02:48:15 +00:00
2025-11-26 18:03:42 +01:00
2025-12-10 16:48:08 +00:00
2025-11-24 13:34:04 +01:00
2025-12-14 22:55:41 -08:00
2025-12-12 11:06:49 +00:00
2025-12-14 03:22:20 +00:00
2025-12-14 22:55:41 -08:00
2025-10-20 08:35:28 -03:00
2025-12-14 03:22:20 +00:00
2025-11-28 08:18:19 +01:00
2025-10-17 18:58:14 +00:00
2025-10-17 18:58:14 +00:00
2025-12-01 12:57:51 +00:00
2025-12-15 04:07:44 +00:00
2025-11-07 22:27:14 +00:00
2025-11-27 14:08:43 +00:00
2025-11-11 12:55:19 +00:00
2025-11-27 13:46:43 +00:00
2025-10-17 18:58:14 +00:00
2025-12-04 12:14:31 +01:00
2025-11-20 12:18:50 +01:00
2025-12-01 22:36:30 -05:00
2025-12-02 16:27:36 +00:00
2025-11-24 13:34:04 +01:00
2025-12-10 00:42:19 +00:00
2025-12-10 17:36:51 -08:00
2025-11-06 09:16:45 +00:00
2025-11-10 23:00:55 -07:00
2025-10-17 18:58:14 +00:00
2025-12-13 00:56:06 +00:00
2025-12-04 15:56:57 -08:00
2025-12-14 21:58:26 +02:00
2025-12-08 22:03:51 +00:00
2025-10-17 18:58:14 +00:00
2025-12-10 07:07:48 +00:00
2025-10-17 18:58:14 +00:00
2025-10-17 18:58:14 +00:00
2025-12-12 11:06:49 +00:00
2025-12-13 11:06:30 -05:00
2025-12-02 16:15:18 -05:00
2025-10-17 18:58:14 +00:00
2025-11-19 12:34:41 +01:00
2025-12-08 19:57:02 +01:00
2025-10-17 18:58:14 +00:00
2025-10-17 18:58:14 +00:00
2025-12-04 03:55:04 +05:30
2025-12-09 09:08:59 +01:00
2025-12-09 20:54:16 +01:00
2025-10-17 18:58:14 +00:00
2025-12-11 17:23:27 +00:00
2025-10-23 14:13:35 -04:00
2025-12-14 20:50:48 -08:00
2025-12-14 20:50:48 -08:00
2025-12-10 17:36:51 -08:00
2025-12-09 15:13:52 +00:00
2025-12-14 20:50:48 -08:00
2025-12-15 02:48:15 +00:00
2025-12-11 22:30:51 +00:00
2025-12-14 22:55:41 -08:00
2025-10-17 18:58:14 +00:00
2025-12-08 21:49:26 +01:00
2025-12-02 22:26:40 +00:00
2025-12-08 21:49:26 +01:00
2025-12-08 21:49:26 +01:00
2025-12-08 13:16:19 +00:00
2025-12-14 22:55:41 -08:00
2025-10-17 18:58:14 +00:00
2025-11-26 16:56:34 +00:00
2025-10-17 18:58:14 +00:00
2025-12-12 14:28:25 +01:00
2025-10-20 10:30:06 +00:00
2025-11-20 22:17:50 -07:00
2025-12-08 19:50:20 +01:00
2025-12-12 14:28:25 +01:00
2025-12-08 13:32:14 -05:00
2025-12-15 02:48:15 +00:00
2025-11-19 22:00:58 +00:00
2025-11-28 15:48:33 -05:00
2025-12-14 11:47:15 -07:00
2025-11-17 12:31:00 +00:00
2025-10-26 13:24:26 +00:00
2025-10-17 18:58:14 +00:00
2025-12-09 09:29:40 -08:00
2025-10-17 18:58:14 +00:00
2025-12-10 12:10:43 -08:00
2025-12-11 19:14:36 +00:00
2025-12-02 21:33:41 +00:00
2025-10-17 18:58:14 +00:00
2025-11-19 22:00:58 +00:00
2025-12-05 20:26:42 +00:00
2025-12-02 21:33:41 +00:00
2025-12-12 14:15:50 +01:00
2025-12-09 13:22:57 +01:00
2025-12-15 04:07:44 +00:00
2025-12-14 22:55:41 -08:00
2025-10-17 18:58:14 +00:00
2025-10-22 19:52:38 +00:00
2025-12-04 03:55:04 +05:30
2025-12-13 01:38:44 +01:00
2025-10-22 19:52:38 +00:00
2025-10-17 18:58:14 +00:00
2025-12-09 09:08:59 +01:00
2025-10-17 18:58:14 +00:00
2025-12-12 11:16:17 +00:00
2025-12-08 14:04:49 +00:00
2025-12-12 09:55:06 +00:00
2025-10-17 18:58:14 +00:00
2025-10-17 18:58:14 +00:00
2025-12-03 21:56:39 +00:00
2025-11-26 18:03:42 +01:00
2025-10-17 18:58:14 +00:00
2025-12-15 02:48:15 +00:00
2025-10-17 18:58:14 +00:00
2025-10-17 18:58:14 +00:00
2025-12-10 12:10:43 -08:00
2025-10-20 17:20:09 +00:00
2025-11-11 16:10:47 +01:00
2025-12-01 20:52:57 -07:00
2025-12-11 15:49:10 -05:00
2025-11-24 13:24:26 -05:00
2025-12-06 18:49:21 +00:00
2025-12-08 21:00:00 +05:30
2025-10-17 18:58:14 +00:00
2025-12-10 12:10:43 -08:00
2025-12-10 07:07:48 +00:00
2025-12-12 11:16:17 +00:00
2025-12-12 14:28:25 +01:00
2025-11-13 14:56:40 +01:00
2025-12-10 18:00:11 +00:00
2025-12-03 21:56:39 +00:00
2025-12-14 03:22:20 +00:00
2025-12-10 18:07:01 -05:00
2025-12-10 12:10:43 -08:00
2025-10-17 18:58:14 +00:00
2025-11-27 13:46:43 +00:00
2025-12-12 11:53:15 +00:00
2025-12-11 21:05:50 +00:00
2025-12-12 06:32:30 -08:00
2025-12-09 09:29:40 -08:00
2025-11-03 19:25:15 +00:00
2025-12-05 17:23:06 +00:00
2025-12-04 14:42:26 +00:00
2025-12-01 18:55:33 +01:00
2025-10-17 18:58:14 +00:00
2025-10-17 18:58:14 +00:00
2025-12-11 22:29:47 +00:00
2025-12-01 09:12:31 +01:00
2025-12-14 03:22:20 +00:00
2025-10-27 10:13:26 -04:00
2025-11-21 08:28:17 -07:00
2025-11-07 22:27:14 +00:00
2025-12-15 04:07:44 +00:00
2025-10-17 18:58:14 +00:00
2025-12-08 21:38:24 +00:00
2025-10-17 18:58:14 +00:00
2025-10-17 18:58:14 +00:00
2025-10-17 18:58:14 +00:00
2025-10-17 18:58:14 +00:00
2025-11-20 01:52:13 -03:00
2025-11-03 19:25:15 +00:00
2025-12-05 17:23:06 +00:00
2025-12-04 15:56:57 -08:00
2025-10-17 18:58:14 +00:00
2025-11-20 12:18:50 +01:00
2025-11-24 13:34:04 +01:00
2025-12-03 22:49:44 +00:00
2025-12-04 15:37:32 -05:00
2025-12-09 09:08:59 +01:00
2025-11-07 11:36:05 +00:00
2025-11-24 13:34:04 +01:00
2025-12-15 08:12:24 +01:00
2025-12-12 11:06:49 +00:00
2025-12-12 14:28:25 +01:00
2025-12-04 03:55:04 +05:30
2025-10-17 18:58:14 +00:00
2025-10-17 18:58:14 +00:00
2025-12-01 20:52:57 -07:00
2025-10-17 18:58:14 +00:00
2025-12-14 02:51:58 +00:00
2025-12-09 21:37:39 +01:00
2025-12-13 11:06:30 -05:00
2025-11-22 23:28:34 -03:00
2025-10-17 18:58:14 +00:00
2025-10-17 18:58:14 +00:00
2025-12-12 13:33:49 +01:00
2025-10-17 18:58:14 +00:00
2025-10-17 18:58:14 +00:00
2025-12-11 22:18:38 +00:00
2025-11-07 22:27:14 +00:00
2025-10-17 18:58:14 +00:00
2025-10-17 18:58:14 +00:00
2025-10-17 18:58:14 +00:00
2025-12-13 11:06:30 -05:00
2025-12-12 06:32:30 -08:00
2025-11-07 22:27:14 +00:00
2025-12-08 16:38:34 +01:00
2025-12-11 22:29:47 +00:00
2025-12-10 12:10:43 -08:00
2025-12-13 11:06:30 -05:00
2025-12-10 17:36:51 -08:00
2025-12-06 17:56:49 +00:00
2025-11-07 22:27:14 +00:00
2025-12-11 22:29:47 +00:00
2025-12-05 17:23:06 +00:00