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
ZSH pollutes environment on macOS even with $SHELL
set to bash
#7886
Comments
I took a quick look at the git blame and it seems the |
This has nothing to do with alacritty, I recommend playing with your shell until it behaves as expected. |
I respectfully disagree. This has something to do with alacritty as alacritty's choice to invoke the user login shell through zsh is what pollutes the environment. It's not expected behaviour that your terminal emulator runs an extra shell. Especially a shell that is not the login shell you picked with no recourse but to fork and compile your own. |
That’s not alacritty doing that, I believe this was a choice macOS made recently. Feel free to change your shell invocation in the alacritty config to get around it though, or write your own wrapper shell as your default shell. |
I even linked the line where alacritty starts the login shell through |
Apologies. I forgot all about that logic and was assuming that something changed when macOS defaulted to ZSH somewhat recently. |
So now I'm curious and I'm trying running the suggested change here: diff --git a/alacritty_terminal/src/tty/unix.rs b/alacritty_terminal/src/tty/unix.rs
index a4b07b74..d559a4e4 100644
--- a/alacritty_terminal/src/tty/unix.rs
+++ b/alacritty_terminal/src/tty/unix.rs
@@ -162,21 +162,12 @@ fn default_shell_command(shell: &str, _user: &str) -> Command {
#[cfg(target_os = "macos")]
fn default_shell_command(shell: &str, user: &str) -> Command {
- let shell_name = shell.rsplit('/').next().unwrap();
-
// On macOS, use the `login` command so the shell will appear as a tty session.
let mut login_command = Command::new("/usr/bin/login");
- // Exec the shell with argv[0] prepended by '-' so it becomes a login shell.
- // `login` normally does this itself, but `-l` disables this.
- let exec = format!("exec -a -{} {}", shell_name, shell);
-
// -f: Bypasses authentication for the already-logged-in user.
- // -l: Skips changing directory to $HOME and prepending '-' to argv[0].
// -p: Preserves the environment.
- //
- // XXX: we use zsh here over sh due to `exec -a`.
- login_command.args(["-flp", user, "/bin/zsh", "-c", &exec]);
+ login_command.args(["-fp", user, shell]);
login_command
} Seems to work for me, so I'm not sure why things are as they are. Also, it's worth noting that having your Hope this helps a bit. |
You can look into the PR that added that is also relatively new thing. Also, none of that triggers if you run the command on your own iirc. |
It just surprised me that all this special logic is skipped if you choose your own shell in the config. Shouldn’t it be applied to custom shells too? |
Careful. Removing the |
With
$SHELL
set to/bin/bash
~/.zshenv
still seems to get run, which is not really great. This is a result of the choice to execute the shell in a very roundabout way throughzsh -c
by default. Is this really necessary? Wouldn't/usr/bin/login -fp $user $SHELL
be sufficient as we seem to counteract the-l
immediately using anexec -a
anyway.If that doesn't work for some reason I can't foresee, perhaps zsh should be executed with
-f
/--no-rcs
System
OS: macOS
Version:
alacritty 0.13.2 (bb8ea18)
The text was updated successfully, but these errors were encountered: