Skip to content

Commit

Permalink
Merge pull request #86 from benjamb/benbrown/expand-paths
Browse files Browse the repository at this point in the history
Expand pass dir path
  • Loading branch information
mtibben committed Jan 27, 2022
2 parents bf8d76a + 1a2ce33 commit 2e56fec
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pass.go
Expand Up @@ -25,6 +25,15 @@ func init() {
}
if cfg.PassDir == "" {
pass.dir = filepath.Join(os.Getenv("HOME"), ".password-store")
} else if strings.HasPrefix(pass.dir, "~") {
if len(pass.dir) > 1 && pass.dir[1] != '/' {
return nil, fmt.Errorf("Cannot expand path: %s", pass.dir)
}
home, err := os.UserHomeDir()
if err != nil {
return nil, err
}
pass.dir = filepath.Join(home, pass.dir[1:])
}

// fail if the pass program is not available
Expand Down

0 comments on commit 2e56fec

Please sign in to comment.