Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down
8 changes: 4 additions & 4 deletions os_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
Loading