Skip to content

fix(windows): quote command-line tokens, drop duplicated argv[0] - #22

Open
LarryHsiao wants to merge 1 commit into
TerminalStudio:mainfrom
LarryHsiao:orthanc-windows-command-quoting
Open

fix(windows): quote command-line tokens, drop duplicated argv[0]#22
LarryHsiao wants to merge 1 commit into
TerminalStudio:mainfrom
LarryHsiao:orthanc-windows-command-quoting

Conversation

@LarryHsiao

@LarryHsiao LarryHsiao commented Jul 27, 2026

Copy link
Copy Markdown
  • build_command() (Windows backend, flutter_pty_win.c) joins executable and arguments into one Win32 command-line string with no quoting, so any executable under a space-containing path — e.g. Git for Windows' default install location, C:\Program Files\Git\bin\bash.exe — breaks: CreateProcessW/the child's own argv-recovery misparses the space as a token boundary.
  • It also writes the executable twice: options->arguments[0] already duplicates it (the Dart side prepends it so Unix's execvp() gets a conventional argv[0] — correct there), but build_command() unconditionally writes its own executable parameter first and iterates all of arguments, including that duplicate.
  • This PR fixes both: quotes each token that contains a space or tab (Windows filenames cannot contain ", so no escaping of embedded quotes is needed), and skips arguments[0] on the Windows side since it isn't a real argument there.

🤖 Generated with Claude Code

build_command() concatenated executable + arguments into one Win32
command line with no quoting, so any executable under a space-containing
path (e.g. the default Git-for-Windows install location,
'C:\Program Files\Git\bin\bash.exe') broke: CreateProcessW/the child's
own argv-recovery misparsed the space as a token boundary.

It also wrote the executable twice: options->arguments[0] already
duplicates it (the Dart side prepends it so Unix's execvp() gets a
conventional argv[0]), but build_command() also unconditionally wrote
its own executable parameter first, then all of arguments including
that duplicate.

Fixes both: quote each token that contains a space or tab (Windows
filenames cannot contain a double quote, so no escaping of embedded
quotes is needed), and skip arguments[0] since it is not a real
argument.
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.

1 participant