Bash tool uses login shell (-l) causing unwanted output

Status Closed — not planned
Maintainer reply ✓ Yes — wolffiex
Activity 12 comments · opened Nov 18, 2025 · closed Jan 27, 2026
💡 Likely answer: A maintainer (wolffiex, collaborator) responded on this thread — see the highlighted reply below.

Issue

Every bash command is executed as a login shell, sourcing ~/.bash_profile / ~/.profile on each invocation. This pollutes command output with login script messages and adds unnecessary overhead.

Steps to Reproduce

  1. Add any output statement to ~/.bash_profile (e.g., echo "Login shell initialized")
  2. Execute any Bash tool command through Claude Code
  3. Observe the extra output from the login script

Verification

$ shopt login_shell
login_shell     on

Expected

Commands should run in non-login shells. The -l flag should not be used unless specifically needed.

Impact

  • Extraneous output in command results
  • Performance overhead from repeatedly sourcing login scripts
  • Unexpected environment modifications

View original on GitHub ↗

12 Comments

github-actions[bot] · 9 months ago

Found 2 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/11684
  2. https://github.com/anthropics/claude-code/issues/2383

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

bnordli · 9 months ago

The other issues are not duplicates. #11684 proposes several solutions, only one of which solves this problem.

Banandana · 9 months ago

I have this problem due to .bash_profile including a CD command to a common workspace directory which screws up claude's Bash tool since the working directory gets modified -_-

xim · 9 months ago

+1 on making shell invocation configurable. I'd additionally want to be able to set the shell used. I'm using zsh but want claude to run bash. Setting "SHELL": "/bin/bash" under "env" in settings.json appears to be ignored.

wolffiex collaborator · 9 months ago

I added a (secret) env var for this: CLAUDE_BASH_NO_LOGIN
Can you try setting this and confirm it's what you want? If it is I will document it at a minimum and consider making it the default

bnordli · 9 months ago

Works for me, thanks.

Unless you can find any reason why the -l flag was added in the first place, I concur with removing it by default.

vimholic · 9 months ago

Tested CLAUDE_BASH_NO_LOGIN - Works Great!

@wolffiex Thank you for implementing this fix! I've tested it thoroughly and it works perfectly.

Test Environment:

  • Windows 11 + Git Bash
  • Had persistent "File has been unexpectedly modified" errors in Edit tool (#11684)

Test Results:

After setting CLAUDE_BASH_NO_LOGIN=1 in ~/.claude/settings.local.json:

Edit Tool: Multiple consecutive Read → Edit operations succeeded
No Errors: "File has been unexpectedly modified" completely resolved
Stable: Works consistently across different file types

Real-World Impact:

This fix also resolves the Edit tool timestamp issue I reported in #11684, confirming that both issues share the same root cause: bash -l sourcing profile scripts.

Feedback:

The fix works excellently! Suggestions for next steps:

  1. Document this env var in official docs
  2. Consider making it default - most tool executions don't need login shell
  3. Possibly add a setting in settings.json schema for better discoverability

Thanks again for the quick turnaround on this!

pra-olo · 9 months ago

Thank you for at least the workaround, this solves an issue I have because I include cd ~ in my login profile to make my tmux workflow easier.

I'd like to see this become the default -- tools should not be starting "login" shells because login profiles commonly include extra setup that's not necessary or appropriate for every subshell invocation.

github-actions[bot] · 8 months ago

This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.

github-actions[bot] · 7 months ago

This issue has been automatically closed due to 60 days of inactivity. If you're still experiencing this issue, please open a new issue with updated information.

github-actions[bot] · 6 months ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.

wolffiex collaborator · 5 months ago

This is a lot late, but this is now the default behavior in Claude Code. Thanks for the feedback!