Artificial intelligent assistant

Why don't subshell expressions in ~/.zshenv lead to infinite regress? I understand that `~/.zshenv` gets sourced every time that an instance of `zsh` starts. This implies that having the following line `~/.zshenv` would result in an infinite regress: (echo "$$ $(date)" >> $HOME/.debug.zshenv) ...because the `(...)` represents a subshell, and hence another sourcing of `~/.zshenv`, etc.1 This reasoning notwithstanding, the line shown above is harmless, AFAICT. In particular, `$HOME/.debug.zshenv` shows only one line after I start a new shell with % zsh Clearly, `~/.zshenv` is not getting sourced anew when the line above is evaluated. Why not? * * * 1For that matter, the expression `$(date)` also entails creating a subshell.

You misunderstand the meaning of subshell. A subshell is not a completely new process but a fork of the existing process.

If you call `zsh` explicitly e.g.


zsh -c 'echo "$$ $(date)" >> $HOME/.debug.zshenv'


then the shell forks, calls `execve()` and by that starts a completely new shell which does the initialization again.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 280660844b8d29a25096e4e22c193398