Skip to content

fix: use single quotes for CLI arg joining to fix backslash escaping#5063

Merged
baszalmstra merged 1 commit intoprefix-dev:mainfrom
baszalmstra:claude/investigate-issue-5054-01NarNd58MhgxeSUenECuBSZ
Dec 5, 2025
Merged

fix: use single quotes for CLI arg joining to fix backslash escaping#5063
baszalmstra merged 1 commit intoprefix-dev:mainfrom
baszalmstra:claude/investigate-issue-5054-01NarNd58MhgxeSUenECuBSZ

Conversation

@baszalmstra
Copy link
Contributor

@baszalmstra baszalmstra commented Dec 4, 2025

Description

This fixes the double-escaping of backslashes in pixi run command arguments.

The issue was a mismatch between shlex::try_join's POSIX double-quote escaping and deno_task_shell's parsing. deno_task_shell doesn't unescape \\ to \ inside double quotes the way POSIX shells do.

The fix uses single quotes where possible (which preserve backslashes literally), and falls back to double quotes for strings containing single quotes.

Before: pixi run echo 'test\ntest'test\\ntest (doubled backslash)
After: pixi run echo 'test\ntest'test\ntest (correct)

Fixes #5054
Fixes #4579

How Has This Been Tested?

In CI and manually:

Old:

> pixi --version
pixi 0.59.0
> pixi run echo 'bar\qux\'
Error:   × failed to parse shell script. Task: 'echo "bar\\qux\\" '
  ╰─▶ Expected closing double quote.
        "bar\\qux\\"
        ~
> pixi run echo 'test\ntest'
test\\ntest

New:

> pixi run echo 'bar\qux\'
bar\qux\
> pixi run echo 'test\ntest'
test\ntest

AI Disclosure

  • This PR contains AI-generated content.
    • I have tested any AI-generated content in my PR.
    • I take responsibility for any AI-generated content in my PR.

Tools: Claude Code Opus 4.5

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added sufficient tests to cover my changes.
  • I have verified that changes that would impact the JSON schema have been made in schema/model.py.

@baszalmstra baszalmstra requested a review from tdejager December 4, 2025 13:38
…refix-dev#5054)

This fixes the double-escaping of backslashes in `pixi run` command arguments.

The issue was a mismatch between shlex::try_join's POSIX double-quote
escaping and deno_task_shell's parsing. deno_task_shell doesn't unescape
`\\` to `\` inside double quotes the way POSIX shells do.

The fix uses single quotes where possible (which preserve backslashes
literally), and falls back to double quotes for strings containing
single quotes.

Before: pixi run echo 'test\ntest' → test\\ntest (doubled backslash)
After:  pixi run echo 'test\ntest' → test\ntest (correct)

Fixes prefix-dev#5054
@baszalmstra baszalmstra force-pushed the claude/investigate-issue-5054-01NarNd58MhgxeSUenECuBSZ branch from 2fda87f to f8d0333 Compare December 4, 2025 13:52
@baszalmstra baszalmstra marked this pull request as ready for review December 5, 2025 08:00
@baszalmstra baszalmstra merged commit a1552a1 into prefix-dev:main Dec 5, 2025
40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pixi run double-escapes backslashes in command arguments since v0.53.0 bug(run): cannot parse arguments that end in a backslash

3 participants