Skip to content

Support Windows paths containing spaces via PowerShell -EncodedCommmand - #32

Closed
linghengqian wants to merge 1 commit into
version-fox:mainfrom
linghengqian:ohos
Closed

linghengqian wants to merge 1 commit into
version-fox:mainfrom
linghengqian:ohos

Conversation

@linghengqian

Copy link
Copy Markdown
Member

Problem

On Windows, the plugin passed paths unquoted to cmd.exe /c because Go's argv re-quoting turns " into \", which cmd.exe misinterprets as a volume-relative path (\path\) and rejects with "The filename, directory name, or volume label syntax is incorrect." This meant paths containing spaces (e.g. C:\Users\John Doe\.vfox) were completely unsupported.

The previous workaround was to skip quoting entirely — unquoted paths break at the first space. The drift check in manifest.lua silently failed rather than crashing, and git operations simply didn't work.

Solution

Route all path-bearing shell commands through PowerShell's -EncodedCommand (base64 UTF-16LE). The encoded string contains only [A-Za-z0-9+/=] — no spaces, no quotes — so Go's EscapeArg cannot mangle it. Inside the PowerShell script, paths are passed as single-quoted strings, which PowerShell handles natively.

Changes

lib/git.lua

  • Added psQuote() for PowerShell single-quote quoting and execPS() for running scripts via -EncodedCommand
  • git(), M.removeDir(), makeParentDir(), M.init() now use PowerShell on Windows
  • probeWithTimeoutWindows reuses execPS, eliminating duplicate base64 code
  • M.init batches git init + git config into a single PowerShell script

lib/manifest.lua

  • Added base64, utf16le, psQuote helpers
  • capture() auto-wraps commands in -EncodedCommand on Windows
  • M.gitRoot uses Get-ChildItem -Directory instead of dir /b /ad
  • New gitRevParse() helper used by M.currentHead and M.write

docs/ohos.md

  • Removed the "Windows home containing a space is not supported" limitation

tests/e2e/windows/

  • Added a new e2e combo (latest-ohos-default-spaces) that sets VFOX_HOME to a path containing a space, exercising the fix end-to-end

@linghengqian linghengqian added the enhancement New feature or request label Sep 30, 2026
@linghengqian linghengqian changed the title Support Windows paths containing spaces via PowerShell `-EncodedCommmand Support Windows paths containing spaces via PowerShell -EncodedCommmand Sep 30, 2026
@linghengqian
linghengqian force-pushed the ohos branch 2 times, most recently from 936ee53 to 077615f Compare September 30, 2026 07:44

@linghengqian linghengqian left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

invalid This doesn't seem right

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant