fix(shims): resolve Windows batch file syntax error in generated shims#556
Merged
Conversation
Fixes #555 The Windows .bat shim template contained problematic syntax that broke CMD batch file parsing: - goto/label (:found_file) inside parenthesized if (...) block - Direct %* expansion inside nested for (...) do (...) block These caused 'was unexpected at this time' errors when running any Go command through the shims on Windows. Solution: - Move file argument detection to a safe subroutine (:detect_file_arg) - Call subroutine using 'call' instead of inline goto/label - Add explicit exit code propagation with exit /b %ERRORLEVEL% This matches the safer approach suggested in the issue report and ensures shims work correctly in both cmd.exe and PowerShell.
Provides comprehensive guidance for AI coding assistants including: - Branch structure and PR guidelines (main vs master) - Platform-specific constraints (Windows batch file gotchas) - Development patterns and testing guidelines - Common tasks and issue resolution checklist This helps AI agents understand project conventions and avoid common pitfalls like Windows batch file syntax errors.
Root-level AI agent instructions that complement .github/copilot-instructions.md. Provides quick-start guidance, architecture overview, and critical Windows development constraints. Multiple locations ensure broader AI tool compatibility: - AGENTS.md (root) - discovered by most AI systems - .github/copilot-instructions.md - GitHub Copilot specific
Enhanced AI agent documentation with: Testing Standards: - Testing philosophy (TDD, coverage goals, performance) - Environment requirements (unset GOENV_DEBUG critical for tests) - Complete test targets reference (make test, test-quick, test-verbose, etc.) - Test organization patterns and naming conventions - Platform-specific testing (Unix/Windows validation) - Test artifacts locations (.test-results/) - PR requirements checklist - Common testing commands quick reference Directory Structure: - Complete cmd/ directory reference (12 command categories) - Complete internal/ directory reference (31 packages) - Clear separation of concerns and package purposes This comprehensive documentation eliminates the need to rebuild context for each PR and ensures consistent development practices across the project.
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.
Summary
Fixes #555
Resolves Windows batch file syntax errors in generated
.batshims that caused") was unexpected at this time"errors when running Go commands on Windows.Problem
The Windows shim template in
internal/shims/manager.gocontained problematic CMD batch syntax:gotocommand and label (:found_file) inside a parenthesizedif (...)block%*expansion inside nestedfor (...) do (...)blockThese patterns break Windows CMD parsing and prevented all shim-based commands from executing.
Solution
:detect_file_arg)call :detect_file_arg %*instead of inline goto/labelexit /b %ERRORLEVEL%Testing
go test -v ./cmd/shims/... ./internal/shims/...)Notes
This fix applies to all generated shims (go.bat, gofmt.bat, golangci-lint.bat, etc.) as they all use the same template.