Skip to content

Quote arguments with spaces in linker wrapper scripts#391

Merged
messense merged 3 commits intomainfrom
quote
Jan 25, 2026
Merged

Quote arguments with spaces in linker wrapper scripts#391
messense merged 3 commits intomainfrom
quote

Conversation

@messense
Copy link
Member

Use shell_words::join to properly quote cc_args when joining them for wrapper scripts. This handles paths with spaces (e.g., cache directory on Windows like C:\Users\Vincent Foo\AppData\Local\...).

Also replaces shlex with shell-words crate throughout, as shell-words is more actively maintained.

Fixes #381

@messense messense force-pushed the quote branch 3 times, most recently from 6df2fc7 to bcdf480 Compare January 25, 2026 03:27
Fix paths with spaces in Windows batch wrapper scripts by using platform-specific
quoting for linker arguments.

Changes:
- Refactor cc_args to push arguments separately (e.g., push "-target" and
  "x86_64-linux-gnu" instead of "-target x86_64-linux-gnu")
- On Unix: use shell_words::join() for single-quote quoting
- On Windows: use custom double-quote quoting for cmd.exe compatibility
- Internal quotes in Windows paths are escaped by doubling ("")

Also replaces shlex with shell-words crate throughout, as shell-words
is more actively maintained.

Fixes #381
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes issue #381 where linking fails when directory paths contain spaces on Windows. The fix involves properly quoting arguments in linker wrapper scripts and replacing the shlex crate with the more actively maintained shell-words crate.

Changes:

  • Replaced shlex dependency with shell-words crate throughout the codebase
  • Split compiler flag arguments (like -target, -include) into separate vector elements to enable proper per-argument quoting
  • Implemented platform-specific argument joining: shell_words::join for Unix, custom quote_for_batch function for Windows batch files
  • Added setlocal DisableDelayedExpansion to Windows batch files to prevent !VAR! expansion issues

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 3 comments.

File Description
Cargo.toml Replaced shlex dependency with shell-words 1.1.1
Cargo.lock Updated lockfile to reflect the dependency change
src/zig.rs Migrated from shlex to shell_words API; split combined arguments into separate elements; implemented custom Windows batch file quoting; added DisableDelayedExpansion to Windows batch wrapper; added tests for quoting functions

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 3 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@messense messense force-pushed the quote branch 2 times, most recently from 2f28e98 to 1e5312d Compare January 25, 2026 06:57
@messense messense merged commit 6c0a8cb into main Jan 25, 2026
40 checks passed
@messense messense deleted the quote branch January 25, 2026 07:52
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.

Linking fails if directory contains a space (presumably on Windows)

2 participants