diff --git a/internal/control/control.go b/internal/control/control.go index bcd1f7a..15c3180 100644 --- a/internal/control/control.go +++ b/internal/control/control.go @@ -7,6 +7,8 @@ import ( "encoding/json" "os" "path/filepath" + "runtime" + "strings" ) const MaxFrameBytes = 8 << 20 @@ -31,7 +33,14 @@ func PipeName() string { if err != nil { exe = "reims-go" } + return pipeNameForExecutable(exe) +} + +func pipeNameForExecutable(exe string) string { identity := filepath.Clean(exe) + if runtime.GOOS == "windows" { + identity = strings.ToLower(identity) + } sum := sha256.Sum256([]byte(identity)) userScope := currentUserScope() return `\\.\pipe\reims-go-control-` + hex.EncodeToString(sum[:8]) + "-" + userScope diff --git a/internal/control/control_test.go b/internal/control/control_test.go new file mode 100644 index 0000000..0595737 --- /dev/null +++ b/internal/control/control_test.go @@ -0,0 +1,17 @@ +package control + +import ( + "runtime" + "testing" +) + +func TestPipeNameWindowsCaseInsensitive(t *testing.T) { + if runtime.GOOS != "windows" { + t.Skip("windows-only path normalization test") + } + upper := pipeNameForExecutable(`D:\Build\reims-go\build\bin\reims-go.exe`) + lower := pipeNameForExecutable(`d:\build\reims-go\build\bin\reims-go.exe`) + if upper != lower { + t.Fatalf("expected case-insensitive pipe name on Windows: %q != %q", upper, lower) + } +}