Repository navigation
fix: stop ~/.bashrc early in non-interactive shells - #37
Merged
Merged
Conversation
bash reads ~/.bashrc for every ssh command. Loading the rc libraries there breaks callers that expect a quiet shell: Ansible's become prompt detection timed out on hosts whose sudo needs a password once bootstrap.sh had run. The bash base block now returns early unless the shell is interactive; the zsh block is unchanged because zsh reads ~/.zshrc only interactively. Existing base blocks are left as they are.
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.
Problem
bash reads
~/.bashrcfor every ssh command. Sincebootstrap.shputs the rc libraries into it, a non-interactive session loaded them too. On hosts wheresudoneeds a password this broke Ansible: its become prompt detection ran intoTimeout (12s) waiting for privilege escalation promptas soon asbootstrap.shhad run for the ssh user (seen while rolling the dotfiles out to Proxmox guests, INFRA-38). Withcase $- in *i*) ;; *) return;; esacat the top of the file it works again.Change
The
dotfiles:baseblock written to~/.bashrcnow returns early unless the shell is interactive:~/.zshrcis unchanged (zsh reads it only for interactive shells).DOTFILESis still exported first, and theDOTFILES=line that the checkout detection parses stays in the same place.Existing base blocks are not rewritten: a run that finds the block already present still skips it. A machine that already ran
bootstrap.shgets the guard when its~/.bashrcis regenerated or the line is added by hand.Test plan
tests/test-bashrc-noninteractive.sh: guard present in.bashrcand absent in.zshrc, placed after theDOTFILESexport; a non-interactivebash -c '. ~/.bashrc'does not load the library, an interactivebash -icdoes.for t in tests/test-*.sh; do bash $t; done: all pass locally.shellcheckwas not available locally; CI runsmake lint.