claude-code - 💡(How to fix) Fix [BUG] Copying long commands from chat UI inserts hidden characters that break terminal execution on macOS [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#49333Fetched 2026-04-17 08:44:12
View on GitHub
Comments
0
Participants
1
Timeline
3
Reactions
0
Participants
Timeline (top)
labeled ×2unlabeled ×1

Error Message

Example: The command helm install datadog-agent datadog/datadog -n datadog -f ~/path/to/values.yaml was split after -f, causing zsh to treat the file path as a separate command and return Error: flag needs an argument: 'f' in -f and zsh: permission denied: ~/path/to/values.yaml.

Root Cause

Impact: This is particularly harmful for non-technical users following step-by-step CLI guidance. The error looks like user error but is caused by the copy mechanism. It required manually retyping commands or breaking them into shorter pieces to work around, adding significant friction across multiple steps.

Code Example

**Example:** The command helm install datadog-agent datadog/datadog -n datadog -f ~/path/to/values.yaml was split after -f, causing zsh to treat the file path as a separate command and return Error: flag needs an argument: 'f' in -f and zsh: permission denied:  ~/path/to/values.yaml.
RAW_BUFFERClick to expand / collapse

Preflight Checklist

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

What's Wrong?

[Important]: claude.ai web UI bug, not a Claude Code CLI bug

Background: Doing exploration with Google Cloud and Datadog agents, a product manager and not hardcore infra expert

Environment: macOS (Apple Silicon, arm64), zsh shell, copying commands from the Claude.ai chat UI in a browser

The problem: When Claude outputs long terminal commands in code blocks, copying them from the chat UI and pasting into the terminal inserts invisible characters at line-wrap points. The shell interprets these as line breaks, splitting a single command into multiple tokens. This causes errors like flag needs an argument: 'f' in -f, zsh: command not found: --set, or zsh: permission denied: <path>, even when the command is syntactically correct.__

What Should Happen?

Impact: This is particularly harmful for non-technical users following step-by-step CLI guidance. The error looks like user error but is caused by the copy mechanism. It required manually retyping commands or breaking them into shorter pieces to work around, adding significant friction across multiple steps.

Error Messages/Logs

**Example:** The command helm install datadog-agent datadog/datadog -n datadog -f ~/path/to/values.yaml was split after -f, causing zsh to treat the file path as a separate command and return Error: flag needs an argument: 'f' in -f and zsh: permission denied:  ~/path/to/values.yaml.

Steps to Reproduce

  1. Open Claude.ai in a browser on macOS (Apple Silicon, zsh shell)
  2. Ask Claude to help with a DevOps or cloud infrastructure task that requires long terminal commands (e.g. installing a Helm chart, running a gcloud command with multiple flags)
  3. Claude responds with a command in a code block that is long enough to visually wrap onto a second line in the UI, for example: helm install datadog-agent datadog/datadog -n datadog -f ~/Testing-app/ecommerce-k8s-datadog/helm/datadog-values.yaml
  4. Click to copy the code block using the copy button (or manually select and copy)
  5. Paste the command into a macOS Terminal (zsh)
  6. Press Enter

Expected result: The command runs as a single line

Actual result: The shell splits the command at the visual line-wrap point, treating the second half as a separate command. Example errors produced:

  • Error: flag needs an argument: 'f' in -f
  • zsh: permission denied: ~/Testing-app/ecommerce-k8s-datadog/helm/datadog-values.yaml
  • zsh: command not found: --set

Note: The issue does not occur when the command is short enough to fit on one line in the UI, or when the user manually types the command instead of copying it.

Claude Model

Sonnet (default)

Is this a regression?

No, this never worked

Last Working Version

No response

Claude Code Version

Claude Sonnet 4.6

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

No response

extent analysis

TL;DR

The issue can be fixed by removing invisible characters inserted at line-wrap points when copying long terminal commands from the Claude.ai chat UI.

Guidance

  • Verify that the issue occurs only when copying commands from the Claude.ai UI and not when typing them manually.
  • Try copying the command using a different method, such as selecting and copying the text instead of using the copy button, to see if the issue persists.
  • Use a tool like cat or a hex editor to inspect the copied command for invisible characters, which may be causing the shell to split the command.
  • As a temporary workaround, manually retype the command or break it into shorter pieces to avoid the line-wrap issue.

Example

No code snippet is provided as the issue is related to character encoding and copying, rather than a specific code problem.

Notes

The issue seems to be specific to the Claude.ai UI and the way it handles long commands. It's possible that the UI is inserting line breaks or other invisible characters that are not visible when copying the command.

Recommendation

Apply workaround: Manually retyping the command or breaking it into shorter pieces can help avoid the issue until a fix is implemented to handle long commands correctly in the Claude.ai UI.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix [BUG] Copying long commands from chat UI inserts hidden characters that break terminal execution on macOS [1 participants]