## 背景 GNU bash 的 login shell 语义:argv[0] 首字符为 - 或带 -l/--login 时,启动链为 /etc/profile → ~/.bash_profile > ~/.bash_login > ~/.profile(取第一个存在的),退出时(login only)source ~/.bash_logout;非登录交互则是 /etc/bash.bashrc + ~/.bashrc。 ## 需求分析 1. **Linux/macOS 等 Unix 是真实需求**(release matrix 含 linux gnu x86_64/aarch64 与 macOS x86_64/aarch64):若 niu 作为 Unix 上的登录 shell(getty/ssh/chsh 场景),仅读 ~/.niubashrc 不够——系统 PATH/环境(/etc/profile、/etc/profile.d/*、用户 profile 链)必须先加载。macOS 的 bash login 链路径与 Linux 相同。 2. **Windows 是兼容需求**:没有真实的「登录」概念,但应接受 -l/--login 参数(生态脚本会传;argv[0] 首字符约定同前),语义上映射到现有交互启动链。 ## 实现要点 - argv[0] 首字符 - 与 -l/--login 都置 login 标志; - **平台门用 `#[cfg(not(windows))]`(覆盖 Linux/macOS/其他 Unix),不要只写 target_os = "linux"**;Unix login 链:/etc/profile → 首个存在的 ~/.bash_profile | ~/.bash_login | ~/.profile(与现有 .niubashrc 启动链的先后:GNU 先 profile 后 rc——.niubashrc 应在 profile 之后作为 niu 自身 rc); - ~/.bash_logout 退出钩子(login only); - Windows:-l/--login 接受并等效现有交互启动; - 非 login 交互的 /etc/bash.bashrc + ~/.bashrc 读取(GNU 非登录交互路径)确认现状。 ## 验收 - Unix(CI 的 linux + macOS 腿都验):login 模式下 PATH 含 /etc/profile 注入的条目;logout 钩子触发; - Windows:-l/--login 接受且行为不回归; - bash -l -c、argv[0] 形态的测试。
Activity