Skip to content

feat(startup): login shell chain /etc/profile -> ~/.bash_profile family (#487) - #489

Merged
caomengxuan666 merged 1 commit into
masterfrom
feat/login-shell
Oct 10, 2026
Merged

caomengxuan666 merged 1 commit into
masterfrom
feat/login-shell

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

closes #487

变更

  • login 标志:argv[0] basename 首字符 - 或 -l/--login(含 -lc/-ilc 组合短旗)置 login 标志(既有机制补齐单测:-rubash、/usr/bin/-bash、-bash.exe 等 argv0 形态)。
  • Unix 登录链(#[cfg(not(windows))],覆盖 Linux 与 macOS 两条 release 腿):login shell 依次 source /etc/profile → 首个存在的 ~/.bash_profile | ~/.bash_login | ~/.profile(缺失静默跳过);非登录交互 shell 依次 source /etc/bash.bashrc(存在时)+ ~/.bashrc(--rcfile/--init-file 只替换个人 rc)。login shell 绝不走 rc 分支(shell.c:1833 if/else),故 bash -lc 只读 profile。
  • ~/.bash_logout 退出钩子(login only):既有 logout builtin 路径已实现(exit.def bash_logout once-per-process 语义),本期不改动。
  • 启动文件 exit:与 --rcfile 路径一致(rubash#297),终止 shell、后续不执行。
  • --noprofile/--norc:现在记录 skip 标记,分别抑制 profile / rc 分支。
  • Windows:无真实登录概念,-l/--login 接受且行为与现状逐字节一致(HOME 含 .bash_profile/.bashrc 也不读)。

测试

  • invocation.rs:注入式存在性检查的链顺序/fallback 单测(bash_profile 优先 → bash_login → .profile → 空链;系统 rc 缺失跳过;rcfile 只替换个人 rc)。
  • main.rs:argv[0] 形态置 login 标志单测。
  • tests/cli_tests.rs:Windows 不回归 CLI 测试(HOME 注入 .bash_profile/.bashrc,-c/-l -c/--login -c/-l -i -c 输出与 stderr 逐字节一致)。
  • 本机全量集成套件与 clean-tree baseline 逐一比对,失败集完全一致(均为本机环境既有失败),零回归。
  • Linux/macOS 端到端(login 模式 PATH 含 /etc/profile 注入条目、logout 钩子触发)交由 CI 对应 job 验证。

…ly (rubash#487)

argv[0] leading '-' or -l/--login (incl. -lc clusters) marks a login
shell; on Unix (not(windows) gate, covering the Linux and macOS release
legs) a login shell sources /etc/profile then the FIRST existing of
~/.bash_profile | ~/.bash_login | ~/.profile, a non-login interactive
shell sources /etc/bash.bashrc + ~/.bashrc (--rcfile replaces only the
personal rc), and `exit` inside a startup file terminates the shell
like the --rcfile path. --noprofile/--norc now record their skips.
Windows accepts -l/--login with zero behavioral change (no real login).

Chain construction lives in invocation.rs with injected existence
checks so fallback order is unit-tested on every host; end-to-end
Linux verification stays with the CI Linux job.
@caomengxuan666
caomengxuan666 merged commit 29da109 into master Oct 10, 2026
7 of 8 checks passed
@caomengxuan666
caomengxuan666 deleted the feat/login-shell branch October 10, 2026 05:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feature] 支持 -l/--login 登录 shell 语义(Linux 全 profile 链;Windows 接受参数)

1 participant