Merge pull request #33 from albertdev/bugfix/platform-indedependent-homedir

Use platform independent os.UserHomeDir() function
This commit is contained in:
Alex Yatskov 2021-12-14 14:18:07 -08:00 committed by GitHub
commit 72ff78498b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -28,6 +28,7 @@ import (
"log"
"os"
"path"
"strings"
)
const (
@ -50,7 +51,7 @@ func usage() {
func main() {
taskName := flag.String("task", "default", "name of task to execute")
dstDir := flag.String("dest", os.Getenv("HOME"), "target directory for tasks")
dstDir := flag.String("dest", "", "target directory for tasks")
force := flag.Bool("force", true, "create parent directories to target")
clobber := flag.Bool("clobber", false, "delete files and directories at target")
verbose := flag.Bool("verbose", false, "verbose output")
@ -94,6 +95,10 @@ func main() {
log.Fatal(err)
}
if strings.TrimSpace(*dstDir) == "" {
*dstDir, _ = os.UserHomeDir()
}
conf.srcDir = makeAbsPath(flag.Arg(1))
conf.dstDir = makeAbsPath(*dstDir)
conf.variant = *variant