Repository navigation
Pass long argument lists to MSYS programs in a response file - #22
Merged
Merged
Conversation
MSYS programs got their arguments on the Windows command line, which is capped at 32,767 characters, so ls over a few hundred files failed with 'The filename or extension is too long'. Git Bash has no such limit. When the arguments would make the command line longer than 30,000 bytes, write them to a delete-on-close response file and pass @"<file>", which the MSYS runtime expands. The file stays open until the program exits. Fixes hex2f#20. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
It sat right after `msys_child`, where hex2f#10 also adds lines, so the two changes conflicted. Declared a few lines up, they merge in either order. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 7, 2026
hex2f
approved these changes
Nov 7, 2026
hex2f
left a comment
Owner
There was a problem hiding this comment.
Thanks for this. It fixes #20. On main, the new 073 test fails with exit 126. With this branch it matches Git Bash.
I also ran ls over 1,200 file names with accented characters (about 49 KB of arguments). Main fails, and this branch matches Git Bash. No gash-args-* files were left in %TEMP%.
The response file's lifetime looks right to me. For a foreground program it's dropped after wait, and for a background job the thread holds it until the process exits.
The branch is based on an older main, but it merges cleanly with current main and with #23 and #25, and the combined compat suite passes 74/74. The response file goes through the same msys_quote that #25 changes, so the two work together.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #20.
MSYS programs got their arguments on the Windows command line, which is capped at 32,767 characters, so a long glob such as
ls logs/*.outover a few hundred files failed with "The filename or extension is too long" (exit 126). Git Bash hands arguments from one MSYS process to the next without the command line, so it has no such limit.When the arguments for an MSYS program (run directly, or as a script's interpreter) would make the command line longer than 30,000 bytes, gash now writes them, quoted with
msys_quoteas before, to a response file and passes@"<file>"instead. The MSYS runtime replaces an@fileargument with the file's contents and parses them like the rest of the command line. Before relying on this I checked it with Git'sprintf.exestarted from a native process:@and*came through as with the command line.@"path with spaces\file"works, but"@file"is taken literally (a quoted@isn't expanded), so the quote goes after the@.@nosuchfilestays literal.The file is a delete-on-close temporary (the existing
temp_file, now also giving its path, from a newtemp_file_named). It stays open until the program has exited. For a background job, which doesn't wait, a thread holds it until the process ends. No file is left behind.Native programs still get the Windows limit, as they do in Git Bash.
Tests
073_msys_long_args.sh, with expected output from Git Bash 5.3.15 viaregen_expected.ps1. It runs the issue's case (1,200 file names, about 49,000 characters) throughls,catand a backgroundls. It also passes a 40,000-character argument to/usr/bin/printftogether with arguments holding spaces, quotes, a backslash, a leading@,*and an empty string, and checks that a native program still fails. It fails without the change:ls,catand the backgroundlsexit 126.cargo testpasses: unit tests, 71/71 compat scripts andmsys_tmp. Nogash-args-*files are left in%TEMP%, and there are no new clippy warnings.