Tuesday, 9 December 2025

Github Copilot's problem with Powershell Here-strings

Problem

When GitHub Copilot (or similar AI coding assistants) uses run_command_in_terminal with PowerShell here-strings (@‘…’@ or @“…”@), the terminal enters continuation mode and hangs indefinitely, waiting for input that never comes.

Symptoms

• Terminal shows >> prompts repeatedly
• Command never completes
• Task eventually times out or must be cancelled with Ctrl+C

Root Cause

PowerShell here-strings require:

  1. The opening delimiter (@’ or @") at the end of a line
  2. Content on subsequent lines
  3. The closing delimiter ('@ or "@) at the start of its own line
    When the AI sends multi-line commands through terminal automation, line breaks aren’t preserved correctly, causing PowerShell to wait forever for the closing delimiter.

Solution: Add to copilot-instructions.md

Add this to your repository’s .github/copilot-instructions.md:

## ⚠️ Terminal Command Limitations

### NEVER Use PowerShell Here-Strings in Terminal Commands

When using `run_command_in_terminal`, **NEVER** use PowerShell here-strings (`@'...'@` or `@"..."@`). They cause the terminal to hang.

### ✅ Alternatives:
1. **For file edits**: Use the `edit_file` tool (preferred)
2. **For simple replacements**: Use single-line `-replace` with escaped patterns
3. **For complex changes**: Provide code to the user to paste manually
4. **If terminal is needed**: Write content to a temp file first

Key Takeaway

AI assistants should never use PowerShell here-strings in terminal commands. Always prefer dedicated file editing tools or provide code snippets for manual pasting when multi-line content is involved.

📝 Originally posted at: https://community.panoramicdata.com/t/github-copilots-problem-with-powershell-here-strings/113

No comments:

Post a Comment