Skip to main content
Clarification
Source Link

What I would like to know is what it will be tomorrow, why, and whether I can lock it down without overriding it.

What I would like to know is what it will be tomorrow, why, and whether I can lock it down.

What I would like to know is what it will be tomorrow, why, and whether I can lock it down without overriding it.

Clarification
Source Link

I should point out that in all my examples thus far the shell has been consistently in both login and interactive states, verified with setopt.


Point of clarification

I should point out that in all my examples thus farThe example I’ve given of the shell has been consistently in bothpath output by loginecho $PATH andat the top of interactive.zshenv states, verified withwhen in Alacritty (thus acquired via setoptlogin -p),

/usr/local/bin:/opt/homebrew/bin:/usr/bin:/bin:/usr/sbin:/sbin 

is an example. It’s not consistent. Sometimes it is that path, sometimes it is

/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin 

and occassionally it is

/usr/bin:/bin:/usr/sbin:/sbin 

What I would like to know is what it will be tomorrow, why, and whether I can lock it down.

I should point out that in all my examples thus far the shell has been consistently in both login and interactive states, verified with setopt.

I should point out that in all my examples thus far the shell has been consistently in both login and interactive states, verified with setopt.


Point of clarification

The example I’ve given of the path output by echo $PATH at the top of .zshenv when in Alacritty (thus acquired via login -p),

/usr/local/bin:/opt/homebrew/bin:/usr/bin:/bin:/usr/sbin:/sbin 

is an example. It’s not consistent. Sometimes it is that path, sometimes it is

/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin 

and occassionally it is

/usr/bin:/bin:/usr/sbin:/sbin 

What I would like to know is what it will be tomorrow, why, and whether I can lock it down.

Update with additional information
Source Link

Update 4

The developers working on Alacritty generously pointed me to the section of their source code responsible for launching new shells (lines 131 through 150).

What it shows is, essentially (when zsh is the default shell),

/usr/bin/login -flp "$USER" /bin/zsh "-c exec -a -zsh /bin/zsh" 

To paraphrase all the man pages, login -p will enter a $PATH into the new shell environment that it gets from pam(3) via environ(7) and execve(2).

The man page for environ(7) explains that login(1), when -p is absent, sets the $PATH to:

/usr/bin:/bin 

Which may explain what I’m seeing in Terminal.app (the source code for which I probably can’t peruse). But this doesn’t account for what echo $PATH is printing when in Alacritty, where login -p is being called:

/usr/local/bin:/opt/homebrew/bin:/usr/bin:/bin:/usr/sbin:/sbin 

Or what /usr/bin/env -i /bin/zsh -l -osourcetrace outputs in both Alacritty and Terminal:

/bin:/usr/bin:/usr/ucb:/usr/local/bin 

At this point my only guess is that pam_launchd.so (listed in /etc/pam.d/login) is where the uncertain and inconsistent initial $PATH, as printed by echo $PATH when in Alacritty, is coming from. But I don't know. And I certainly don't know why.

As for the odd (albeit consistent) /usr/bin/env -i /bin/zsh -l -osourcetrace output including /usr/ucb — a very old default leaking out of but ultimately overridden by Zsh?


Update 4

The developers working on Alacritty generously pointed me to the section of their source code responsible for launching new shells (lines 131 through 150).

What it shows is, essentially (when zsh is the default shell),

/usr/bin/login -flp "$USER" /bin/zsh "-c exec -a -zsh /bin/zsh" 

To paraphrase all the man pages, login -p will enter a $PATH into the new shell environment that it gets from pam(3) via environ(7) and execve(2).

The man page for environ(7) explains that login(1), when -p is absent, sets the $PATH to:

/usr/bin:/bin 

Which may explain what I’m seeing in Terminal.app (the source code for which I probably can’t peruse). But this doesn’t account for what echo $PATH is printing when in Alacritty, where login -p is being called:

/usr/local/bin:/opt/homebrew/bin:/usr/bin:/bin:/usr/sbin:/sbin 

Or what /usr/bin/env -i /bin/zsh -l -osourcetrace outputs in both Alacritty and Terminal:

/bin:/usr/bin:/usr/ucb:/usr/local/bin 

At this point my only guess is that pam_launchd.so (listed in /etc/pam.d/login) is where the uncertain and inconsistent initial $PATH, as printed by echo $PATH when in Alacritty, is coming from. But I don't know. And I certainly don't know why.

As for the odd (albeit consistent) /usr/bin/env -i /bin/zsh -l -osourcetrace output including /usr/ucb — a very old default leaking out of but ultimately overridden by Zsh?


Updates with additional information
Source Link
Loading
added 9 characters in body
Source Link
Loading
Source Link
Loading