Fix for ignored trailing path separator in prefix.

This commit is contained in:
Paweł Błaszczyk 2014-01-03 18:46:33 +01:00
parent 79847ab3e9
commit 7bd7bcfcdf

View File

@ -11,6 +11,7 @@ import (
"os" "os"
"path" "path"
"path/filepath" "path/filepath"
"strings"
"unicode" "unicode"
) )
@ -90,7 +91,14 @@ func parseArgs() {
pipe = flag.NArg() == 0 pipe = flag.NArg() == 0
if !pipe { if !pipe {
sepsuffix := false
if strings.HasSuffix(*prefix, string(filepath.Separator)) {
sepsuffix = true
}
*prefix, _ = filepath.Abs(filepath.Clean(*prefix)) *prefix, _ = filepath.Abs(filepath.Clean(*prefix))
if sepsuffix {
*prefix += string(filepath.Separator)
}
in, _ = filepath.Abs(filepath.Clean(flag.Args()[0])) in, _ = filepath.Abs(filepath.Clean(flag.Args()[0]))
*out = safeFilename(*out, in) *out = safeFilename(*out, in)
} }