0

I've been playing around changing the default login shell of my user using a combination of /etc/shells and chsh.

This was needed, as I wanted to change from the default shell (/bin/zsh) to /opt/homebrew/bin/zsh, and the latter was compiled for arm64.

This worked fine until I accidentally deleted Brew's zsh, which resulted in the terminal being unable to run shells, until I configured a custom command (e.g. /bin/zsh). This allowed me to reinstall Brew's zsh, but what surprised me was that $SHELL expanded to /opt/homebrew/bin/zsh, despite actually running /bin/zsh.

Now, since I can't really rely on $SHELL, I attempted to lookup the actual shell using ps -Af, but that doesn't show the full path?

➜  ~ ps -Af | grep -ie zsh
  502 12860 12856   0  2:08PM ttys000    0:00.94 -zsh
  502 16303 12860   0  2:09PM ttys000    0:00.00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn --exclude-dir=.idea --exclude-dir=.tox -ie zsh
  502 11291 11290   0  2:06PM ttys002    0:00.82 -zsh
Shuzheng
  • 4,023
  • 1
  • 31
  • 71
  • 3
    ... see [Why is echo $SHELL always showing /bin/bash?](https://unix.stackexchange.com/a/330242/65304) – steeldriver Jul 18 '23 at 12:22
  • I 'd use `ps -fp$PPID`, or, if `$PPID` is not defined by your mutant shell, get the parent process's PID from `ps -fp$$`. – waltinator Jul 18 '23 at 16:37
  • @waltinator That shows the `login` command, not the shell – Shuzheng Jul 18 '23 at 16:51
  • @waltinator not the parent pid but the current pid, because the shell is the entity that will expand the variable reference, not the `ps` process. `ps -fp $$` is correct here. – Sotto Voce Jul 18 '23 at 23:14

0 Answers0