Repository navigation
feat(startup): login shell chain /etc/profile -> ~/.bash_profile family (#487) - #489
Merged
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes #487
变更
-或-l/--login(含-lc/-ilc组合短旗)置 login 标志(既有机制补齐单测:-rubash、/usr/bin/-bash、-bash.exe等 argv0 形态)。#[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):既有logoutbuiltin 路径已实现(exit.def bash_logout once-per-process 语义),本期不改动。exit:与--rcfile路径一致(rubash#297),终止 shell、后续不执行。--noprofile/--norc:现在记录 skip 标记,分别抑制 profile / rc 分支。-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 逐字节一致)。