From 8e6aca418259328c7df4a50f8c3bf6d559cc6759 Mon Sep 17 00:00:00 2001 From: Garth Kidd Date: Sun, 17 Jan 2016 11:24:54 +1100 Subject: [PATCH] Use filepath.Join, not string math. Fixes #226. --- doc/man_docs.go | 5 +++-- doc/md_docs.go | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/doc/man_docs.go b/doc/man_docs.go index 942b0aa..f21d839 100644 --- a/doc/man_docs.go +++ b/doc/man_docs.go @@ -18,6 +18,7 @@ import ( "fmt" "io" "os" + "path/filepath" "sort" "strings" "time" @@ -46,8 +47,8 @@ func GenManTree(cmd *cobra.Command, header *GenManHeader, dir string) error { } needToResetTitle := header.Title == "" - filename := cmd.CommandPath() - filename = dir + strings.Replace(filename, " ", "-", -1) + ".1" + basename := strings.Replace(cmd.CommandPath(), " ", "_", -1) + ".1" + filename := filepath.Join(dir, basename) f, err := os.Create(filename) if err != nil { return err diff --git a/doc/md_docs.go b/doc/md_docs.go index 666e949..fa13631 100644 --- a/doc/md_docs.go +++ b/doc/md_docs.go @@ -17,6 +17,7 @@ import ( "fmt" "io" "os" + "path/filepath" "sort" "strings" "time" @@ -156,8 +157,8 @@ func GenMarkdownTreeCustom(cmd *cobra.Command, dir string, filePrepender, linkHa } } - filename := cmd.CommandPath() - filename = dir + strings.Replace(filename, " ", "_", -1) + ".md" + basename := strings.Replace(cmd.CommandPath(), " ", "_", -1) + ".md" + filename := filepath.Join(dir, basename) f, err := os.Create(filename) if err != nil { return err