diff --git a/eval.go b/eval.go index 07b15709..3866e0cd 100644 --- a/eval.go +++ b/eval.go @@ -403,7 +403,12 @@ func (e *setExpr) eval(app *app, _ []string) { return } case "shell": - gOpts.shell = e.val + if strings.EqualFold(e.val, "cmd") { + // Enforce lowercase spelling to simplify special handling later. + gOpts.shell = "cmd" + } else { + gOpts.shell = e.val + } case "shellflag": gOpts.shellflag = e.val case "shellopts": diff --git a/os_windows.go b/os_windows.go index ed1b5385..cbb4186b 100644 --- a/os_windows.go +++ b/os_windows.go @@ -123,8 +123,8 @@ func detachedCommand(name string, arg ...string) *exec.Cmd { } func shellCommand(s string, args []string) *exec.Cmd { - // Windows CMD requires special handling to deal with quoted arguments - if strings.ToLower(gOpts.shell) == "cmd" { + // Windows cmd requires special handling to deal with quoted arguments. + if gOpts.shell == "cmd" { var builder strings.Builder builder.WriteString(s) for _, arg := range args { @@ -221,8 +221,8 @@ func errCrossDevice(err error) bool { } func quoteString(s string) string { - // Windows CMD requires special handling to deal with quoted arguments - if strings.ToLower(gOpts.shell) == "cmd" { + // Windows cmd requires special handling to deal with quoted arguments. + if gOpts.shell == "cmd" { return fmt.Sprintf(`"%s"`, s) } return s