Skip to content

Conversation

@pull
Copy link

@pull pull bot commented Oct 5, 2025

See Commits and Changes for more details.


Created by pull[bot] (v2.0.0-alpha.4)

Can you help keep this open source service alive? 💖 Please sponsor : )

seefood and others added 3 commits October 4, 2025 21:50
Implements the auto-fix portion of issue #1455 (Solaris/Illumos support).

**Problem:**
On macOS, BSD, Solaris, and Illumos, login shells source .bash_profile or
.profile, NOT .bashrc. Users would install bash-it successfully but find it
doesn't load in:
- Terminal.app (macOS default terminal)
- SSH sessions
- Any new login shell

**Solution:**
During installation, automatically detect and fix .bashrc sourcing:

1. **Platform Detection:**
   - Only runs on affected platforms (Darwin, SunOS, Illumos, *BSD)
   - Linux users unaffected (no extra prompts)

2. **Smart Detection:**
   - Reuses `_bash-it-doctor-check-profile-sourcing-grep()` from doctor
   - Fast grep-based detection of existing sourcing patterns
   - Skips if already configured

3. **Interactive Prompt:**
   - Prompts user: "Would you like to add .bashrc sourcing? [Y/n]"
   - Shows manual instructions if user declines
   - Silent mode: auto-accepts (safe default behavior)

4. **Safe Modifications:**
   - Backs up profile file with timestamp before modifying
   - Uses `command cp` to bypass aliases
   - Creates .bash_profile if no profile file exists
   - Appends standard BASH_VERSION check snippet

**User Experience:**

Before (macOS user):
```
$ bash-it install
Installation finished successfully!
$ # opens new terminal... bash-it doesn't work! 😞
```

After (macOS user):
```
$ bash-it install
...
Warning: .bashrc is not sourced from /Users/me/.bash_profile
Would you like to add .bashrc sourcing? [Y/n] y
✓ Added .bashrc sourcing to /Users/me/.bash_profile
Installation finished successfully!
$ # opens new terminal... bash-it works! 😃
```

**Testing:**
- ✅ Shellcheck passes
- ✅ Detection logic tested
- ✅ Silent mode compatible
- ✅ Handles missing profile files

Closes #1455

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Apply defensive shell scripting best practice to prevent errors when
`set -u` (nounset) is active in user shells. Replace `$BASH_VERSION`
with `${BASH_VERSION-}` in both:
- Manual instructions shown to users
- Auto-generated .bash_profile snippet

This ensures the check works correctly even when BASH_VERSION is unset
(e.g., when running under non-bash shells like dash or sh).

Also documents this pattern in CLAUDE.md for future development.

Addresses review feedback from @akinomyoga in PR #2343

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@pull pull bot locked and limited conversation to collaborators Oct 5, 2025
@pull pull bot added the ⤵️ pull label Oct 5, 2025
@pull pull bot merged commit 9e62a5b into devliq:master Oct 5, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant