Skip to content

Commit

Permalink
cmd: throw error when using multiple input files (such as when using …
Browse files Browse the repository at this point in the history
…*) to a non-existing output directory in line with cp behaviour, fixes #562
  • Loading branch information
tdewolff committed Mar 14, 2023
1 parent 727bb66 commit f123d2f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions cmd/minify/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ func run() int {
}

if help {
flag.Usage()
f.Usage()
return 0
}

Expand Down Expand Up @@ -347,13 +347,14 @@ func run() int {
inputs[i] = filepath.Clean(input)
}

// set output, empty means stdout, ending in slash means a directory, otherwise a file
// set output file or directory, empty means stdout
dirDst := false
if output != "" {
dirDst = IsDir(output)
if !dirDst {
if 1 < len(inputs) && !bundle {
dirDst = true
Error.Printf("stat %v: no such file or directory\n", output)
return 1
} else if len(inputs) == 1 {
if info, err := os.Lstat(inputs[0]); err == nil && !bundle && info.Mode().IsDir() && info.Mode()&os.ModeSymlink == 0 {
dirDst = true
Expand Down

0 comments on commit f123d2f

Please sign in to comment.