zed icon indicating copy to clipboard operation
zed copied to clipboard

Use user's default shell in Zed's terminal

Open snokpok opened this issue 5 months ago • 3 comments

Context:

  • I did some digging and found that Alacritty (which we forked) by default does not use the user's $SHELL, but instead uses what's specified in /etc/passwd if any. This PR starts it with $SHELL by default if $SHELL is set.

Release Notes:

  • Fixed https://github.com/zed-industries/zed/issues/5320

snokpok avatar Jan 28 '24 04:01 snokpok

We require contributors to sign our Contributor License Agreement, and we don't have @snokpok on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.

cla-bot[bot] avatar Jan 28 '24 04:01 cla-bot[bot]

Adding @mikayla-maki as a reviewer, as she is more familiar with the terminal code 😄

maxdeviant avatar Jan 28 '24 05:01 maxdeviant

Aside: is /etc/passwd even relevant on macOS? I think the actual source of truth is whatever it is the following command consults dscl . -read $HOME UserShell

frou avatar Jan 28 '24 08:01 frou

Aside: is /etc/passwd even relevant on macOS? I think the actual source of truth is whatever it is the following command consults dscl . -read $HOME UserShell

~~IIRC macOS uses /etc/master.passwd for that stuff, which uses a different format, but an /etc/passwd file is automatically generated for compatibility with programs that read /etc/passwd~~

Nevermind, I think this is true for older versions but on my mac /etc/passwd and /etc/master.passwd contain default info, my user isn't even in there and root has a default shell of /bin/sh instead of /bin/zsh

Un1q32 avatar Jan 29 '24 05:01 Un1q32

  • I did some digging and found that Alacritty (which we forked) by default does not use the user's $SHELL, but instead uses what's specified in /etc/passwd if any. This PR starts it with $SHELL by default if $SHELL is set.

This code in alacritty tells me that they do check $SHELL first:

https://github.com/alacritty/alacritty/blob/7c046f5ae664f746c5f5a4bbe18c0e89f5702305/alacritty_terminal/src/tty/unix.rs#L136-L158

I'm wondering whether the problem isn't that $SHELL isn't set at this point yet?

mrnugget avatar Jan 29 '24 11:01 mrnugget

Yeah, this PR isn't correct. I debugged this with a user several months ago and it turned out Zed wasn't loading the SHELL environment variable somehow. The relevant code is in main.rs.

mikayla-maki avatar Jan 29 '24 17:01 mikayla-maki