Repository navigation
Source ~/.bashrc in bash bootstrap so user aliases are not silently dropped - #16666
Open
CuriousTank wants to merge 1 commit into
Open
CuriousTank wants to merge 1 commit into
CuriousTank wants to merge 1 commit into
Conversation
…ropped (warpdotdev#16631) The bash bootstrap emulates a login sequence (/etc/profile -> ~/.bash_profile | ~/.bash_login | ~/.profile) and never reads ~/.bashrc, even though Warp runs bash as an interactive shell. Aliases and functions that live only in ~/.bashrc therefore never exist inside Warp while working fine in other terminals. The most visible casualty: a user wrapper like alias ssh="trzsz -d ssh" is silently dropped, and the bootstrap's own ssh() function takes over interactive ssh invocations, bypassing the wrapper. Mirror the interactive startup sequence after the login files: source ~/.bashrc for interactive shells, guarded by a sentinel so users whose login rcfile already re-sources ~/.bashrc don't get it twice. Since bash resolves aliases before functions, a user ssh alias now wins over the bootstrap's ssh() function naturally; sessions without such an alias keep warpifying exactly as before. Adds an integration test (test_bash_bootstraps_sources_bashrc_aliases) with an alias living solely in ~/.bashrc, plus a ShellRcType::BashRc helper variant so tests can target ~/.bashrc. write_all_rc_files_for_test skips the new variant to keep existing 'sourced once' assertions meaningful.
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.
Description
Fixes #16631.
The bash bootstrap emulates a login sequence (
/etc/profile→~/.bash_profile|~/.bash_login|~/.profile) and never reads~/.bashrc— but Warp runs bash as an interactive shell, and~/.bashrcis where interactive bash config (aliases, functions) normally lives. So anything defined only there works in gnome-terminal or kitty but silently doesn't exist inside Warp.The nastiest version of this: the bootstrap installs its own
ssh()function before sourcing user rcfiles. A user withalias ssh="trzsz -d ssh"in~/.bashrc(a common drag-and-drop upload setup) never gets the alias, and every interactivesshfalls through to the bootstrap's function — the wrapper is bypassed with no warning. That's the case reported in #16631.The fix mirrors the interactive startup sequence after the login files: source
~/.bashrcfor interactive shells, guarded by a sentinel env var so users whose login rcfile already re-sources~/.bashrcdon't get it twice. No changes to the takeover logic itself — since bash resolves aliases before functions, a user alias now simply wins over thessh()function, and sessions without such an alias behave exactly as before.zsh (
.zshrcis already in its bootstrap sequence) and fish (config.fish is loaded natively) were never affected.Linked Issue
ready-to-specorready-to-implement.#16631 is triaged as
bug/area:ssh/repro:highbut hasn't receivedready-to-implementyet. Happy to wait for the label — mentioning it here so it's visible rather than trying to slip past the gate.Testing
./script/runAdded
test_bash_bootstraps_sources_bashrc_aliases: an alias living solely in~/.bashrc, a.bash_profilethat does not re-source it (the reporter's layout). After bootstrap, runningsshmust execute the alias — if the fix regresses,sshreaches the bootstrap'sssh()function instead and the assertion fails. Also added aShellRcType::BashRchelper so tests can target~/.bashrc;write_all_rc_files_for_testskips that variant so existing "sourced once" assertions stay meaningful.What I ran locally (Linux, bash 5.0):
./script/lint_shellcheck— clean./script/format --check— cleantest_rc_files_only_sourced_once_during_bootstrapping,test_alias_guards_on_ps1_set,test_bash_bootstraps_with_prompt_command_array,test_custom_ps1_expansion_bash— all passalias ssh="trzsz -d ssh"in~/.bashrcand no re-sourcing in~/.bash_profile,type sshinside Warp now shows the alias andssh user@hostgoes through trzsz;\ssh user@hoststill warpifies as before. Also checked the no-~/.bashrcand already-re-sourced layouts — no double-sourcing, no behavior change.Screenshots / Videos
No visible UI surface — the change only affects which rcfiles the bash bootstrap sources.
CHANGELOG-BUG-FIX: bash bootstrap now sources ~/.bashrc, so aliases and functions defined there (e.g. ssh wrappers like trzsz) are no longer silently dropped in Warp
Agent Mode