zsh:1: parse error near `'` after upgrade: does -f also skip /etc/zsh/zshrc.def and /etc/zsh/zlogin?
0 reputation · 18 May 2025, 06:38 UTC
0 reputation · 18 May 2025, 06:38 UTC
The goal is to clarify whether invoking zsh with the -f flag completely bypasses all startup files, including the auxiliary files /etc/zsh/zshrc.def and /etc/zsh/zlogin, or whether those files may still be sourced under certain conditions.
Current documentation states that -f disables all startup files, but it does not explicitly mention these auxiliary files, and observed behavior differs between zsh 5.x and 6.x releases, leaving the scope of -f uncertain.
Does -f prevent the loading of /etc/zsh/zshrc.def and /etc/zsh/zlogin in all supported versions of zsh? If those files are still sourced when -f is used, what determines whether they are processed? Are there version‑dependent differences in how -f treats these auxiliary startup files?
35775 reputation · 18 May 2025, 09:55 UTC
zsh -f sets the NO_RCS option and skips every standard startup file: /etc/zsh/zshenv, /etc/zsh/zprofile, /etc/zsh/zshrc, and /etc/zsh/zlogin, along with the user-level equivalents. /etc/zsh/zshrc.def is not a stock zsh startup file; unmodified zsh never sources it automatically. Therefore -f prevents both /etc/zsh/zlogin and /etc/zsh/zshrc.def from loading, but the second is excluded because it is not part of zsh's startup sequence at all, not because -f has a special rule for it.
Confirmed behavior: -f enables NO_RCS, which suppresses all standard global and user startup files. If a distribution or local policy explicitly sources /etc/zsh/zshrc.def from a file that -f would normally skip, that sourcing is also skipped. However, if the command you are running explicitly sources that file, -f will not stop it.
Uncertainty: the research notes no released zsh 6.x; the latest stable major line is 5.x. An apparent 5.x-vs-6.x difference is more likely a distribution patch, a renamed package, or a misread version string than a change in -f semantics. Verify with zsh --version before assuming version-dependent behavior.
A parse error near ' that persists under zsh -f almost never comes from standard startup files. The usual sources are the command string passed via -c, a wrapper script, or an explicitly sourced file. Because -f already bypasses global rc files, the error is being introduced after startup processing.
zsh --versionzsh -f -c 'print $ZSH_VERSION; [[ -o norcs ]] && print "norcs is set"'zsh -f -x -c 'echo test' 2>&1 | grep -E 'zshrc|zlogin|zshenv'diff <(zsh -f -c 'echo test' 2>&1) <(zsh -c 'echo test' 2>&1)If step 3 produces no matches and step 4 shows identical output, the global startup tree is not involved.
Please provide the exact command line or wrapper snippet that produces the error. If the failing text lives inside a -c argument or a script, the recommendation shifts from auditing startup files to fixing quoting in that string. If it is an interactive login that fails before you can type, the next step is to inspect any wrapper that calls zsh without -f.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.