11// TestResolveInterpreter_PermissiveFallback_Windows is the Windows-native
12// counterpart to the POSIX permissive-fallback test. It proves the one
13// behavior that makes `#!/bin/bash` hooks work on a stock Windows box
14// with Git for Windows installed: when the literal interpreter path does
15// not exist, we fall back to a PATH-lookup on the basename and that
16// lookup accepts any executable extension Windows honors (here, `.bat`).
18// We plant a bash.bat in a tempdir rather than a .exe because producing
19// a .exe would require a toolchain step; LookPath on Windows resolves
20// PATHEXT extensions, so .bat is just as valid for the lookup codepath.
21func TestResolveInterpreter_PermissiveFallback_Windows(t *testing.T) {
23 fake := filepath.Join(dir, "bash.bat")
24 contents := "@echo off\r\nexit /b 0\r\n"
25 if err := os.WriteFile(fake, []byte(contents), 0o755); err != nil {
26 t.Fatalf("write fake bash.bat: %v", err)
29 t.Setenv("PATHEXT", ".BAT;.CMD;.EXE")
31 // Literal path must be absent so the stat fails with ENOENT.
32 missing := filepath.Join(dir, "definitely-not-here-"+randSuffix(), "bash")
33 resolved, err := resolveInterpreter(missing)
35 t.Fatalf("expected fallback to succeed, got: %v", err)
38 t.Fatalf("resolved = %q, want %q", resolved, fake)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list