[BUG] "Multi-line bash commands split into invalid permission entries when using 'Always allow'"

Resolved 💬 3 comments Opened Jan 6, 2026 by erikg Closed Jan 10, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

When approving a multi-line bash command (e.g., a for loop or while loop) with "Always allow", the permission system incorrectly splits the command by newlines and creates separate entries for each line fragment. These fragments are invalid as standalone permissions and will never match any real command.

What Should Happen?

Either:

  • Store the complete multi-line command as a single permission entry, or
  • Decline to create an "always allow" rule for multi-line commands

Error Messages/Logs

Actual behavior:

  The command is split by newlines into separate entries:
  {
    "permissions": {
      "allow": [
        "Bash(for d in */)",
        "Bash(do echo \"$d\")",
        "Bash(done)"
      ]
    }
  }

  Another example (from a while loop):
  "Bash(while read d)",
  "Bash(do if [[ \"$d\" == *ca47b3bc2* ]])",
  "Bash(then echo \"$d\")",
  "Bash(fi)"

  These fragments are useless - they will never match any command and just pollute the settings file.

Steps to Reproduce

  1. Run a multi-line bash command, such as:

for d in */
do echo "$d"
done

  1. When prompted, select "Always allow"
  2. Check .claude/settings.local.json

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.0.76

Platform

Anthropic API

Operating System

Ubuntu/Debian Linux

Terminal/Shell

Other

Additional Information

Environment:

  • Claude Code version: 2.0.76
  • Platform: Linux 6.8.0-90-generic
  • Shell: bash

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗