Expand description
emulation_startup submodule — per-drop-in startup/logout files (Rust-only).
Startup- and shutdown-file model for every zshrs emulation drop-in.
zshrs-only — no zsh C counterpart. Src/init.c::run_init_scripts
knows exactly two startup-file sets: zsh’s
(zshenv/zprofile/zshrc/zlogin) and a single lumped Bourne one
(/etc/profile + ~/.profile + $ENV). That is enough for upstream,
which only ever emulates sh/ksh loosely. zshrs ships drop-ins for
eight shells and each has its own set, so the whole table lives here.
Every row below was read off the shell’s own manual AND verified by
running the reference binary with a scratch $HOME in which each
candidate file echoes its own name:
| personality | login shell | interactive non-login | non-interactive |
|---|---|---|---|
--bash | /etc/profile, first of ~/.bash_profile / ~/.bash_login / ~/.profile | /etc/bash.bashrc†, ~/.bashrc | $BASH_ENV |
--ksh | /etc/profile, ~/.profile, then the interactive file | /etc/ksh.kshrc†, $ENV (default ~/.kshrc) | — |
--mksh | /etc/profile, ~/.profile, then the interactive file | $ENV, or ~/.mkshrc when $ENV is unset | — |
--pdksh | /etc/profile, ~/.profile, then the interactive file | $ENV (no default) | — |
--sh / --posix / --dash / --ash | /etc/profile, ~/.profile, then the interactive file | $ENV (no default) | — |
--csh | the non-login files, then /etc/csh.login, ~/.login | /etc/csh.cshrc, ~/.tcshrc or ~/.cshrc | — |
† existence-gated: see [sys_file].
Reference runs (printf 'true\n' | env -i HOME=… <shell> <flags>):
bash 5.3.15:-l -c true→.bash_profile; with it removed →.bash_login; with both removed →.profile;-i -c true→.bashrc;-i -l -c true→.bash_profileand NOT.bashrc;script.sh→$BASH_ENV;-l script.sh→.bash_profilethen$BASH_ENV;-i -c truewith$BASH_ENVset →.bashrconly;--norc -i/--noprofile -l→ nothing;--rcfile F -iand--init-file F -i→F;-l -c exit→.bash_profile,.bash_logout.ksh93(/bin/ksh, macOS):-i→.kshrc;-iwith$ENVset → that file;-l→.profile;-i -l→.profilethen.kshrc.mksh 59c:-i→.mkshrc;-iwith$ENV→ that file;-l→.profile;-i -l→.profilethen.mkshrc.dash:-i→ nothing without$ENV;-iwith$ENV→ that file;-l→.profile;-i -lwith$ENV→.profilethen$ENV.tcsh(macOS/bin/csh):-i→.tcshrc, or.cshrcwhen.tcshrcis absent;-l→.tcshrcthen.login.
pdksh itself is not installed here; its $ENV-with-no-default rule is
taken from ksh(1) on OpenBSD, which tells the user to set it by hand
(“export ENV=$HOME/.kshrc”) — the sentence mksh(1) replaces with its
own ~/.mkshrc fallback.
Two deliberate divergences, both marked at their call site:
- The system-wide rc files bash and ksh93 compile in (
SYS_BASHRC,/etc/ksh.kshrc) are sourced when they EXIST. zshrs ships one binary to every platform and cannot bake in a packager’s-DSYS_BASHRC; Debian/Ubuntu/Arch define it and ship the file, macOS defines neither — so “exists” reproduces both. Same reasoning ascrate::extensions::global_rc. - bash’s
rshd/sshdnetwork-stdin case (a non-interactive shell whose stdin is a socket reads~/.bashrc) is not modeled.
Enums§
- Personality
- Which shell zshrs is standing in for. Selected once by the binary’s
CLI mode application (
--bash,--ksh, anargv[0]symlink, …) and read wherever behavior forks per drop-in.
Functions§
- apply_
personality_ option_ deltas - Re-apply the selected drop-in’s option deltas on top of the
emulatepreset it shares with another shell. - default_
aliases - The aliases this personality starts with, or
Noneto leave zsh’s own defaults (run-help,which-command) in place. - emits_
bracketed_ paste - Whether this drop-in writes the bracketed-paste enable/disable pair
(
\e[?2004h/\e[?2004l) around its line editing. - emits_
integration_ prompt - Whether this drop-in writes the OSC 133 shell-integration marker
before each prompt. It is a zsh feature — bash does not send one, and
neither does zsh 5.9 with its default
.term.extensions— so only native zshrs keeps it. - emulating
- True when this process is standing in for another shell — any
--MODEflag orargv[0]inference,--zshincluded. - explicit_
login - True when
-l/--loginwas given explicitly. See [EXPLICIT_LOGIN]. - install_
default_ aliases - Replace the alias table’s contents with this personality’s defaults.
Called once during CLI mode selection, before any startup file runs,
so a user’s own
aliasstill wins. - logout_
files - The ordered files read when a LOGIN shell exits, given whether the shell is interactive.
- noprofile
- True when
--noprofilewas given. - norc
- True when
--norcwas given. - overrides_
zsh_ startup - True when this drop-in owns its own startup files, i.e. the faithful
run_init_scriptsport must NOT run for it. - personality
- The selected drop-in, defaulting to
Personality::Zsh. - rcfile
- The
--rcfileoverride, if one was given. - run_
init_ scripts - Source the selected drop-in’s startup files. Library-side entry
point, called from the
run_init_scriptshook. - run_
logout_ scripts - Source the selected drop-in’s logout files on the way out of a login
shell. Called from
zexit, where zsh reads.zlogout. - selected_
emulate_ name - The
emulatename to install, orNonewhen no drop-in was selected and the faithfulargv[0]derivation should stand. - set_
emulating - Record that a parity / drop-in mode was selected. Called once from
the binary’s CLI mode application, for every
--MODEand everyargv[0]inference. - set_
explicit_ login - Record that login-ness came from an explicit
-l/--login. - set_
noprofile - Set/clear
--noprofile. - set_
norc - Set/clear
--norc. - set_
personality - Record the drop-in the user asked for. Called once from the binary’s CLI mode application, before any user code runs.
- set_
rcfile - Record
--rcfile FILE/--init-file FILE. - single_
quote - Single-quote a value the way bash’s
alias/declare -plistings do: wrap in'…'and render an embedded quote as'\''. - startup_
files - The ordered startup files the selected drop-in reads. Returned rather
than sourced so the library’s
run_init_scriptshook and the binary’s-c/ script-file dispatch drive the SAME list through their own sourcing machinery.