Skip to content

Commit

Permalink
added fallback in case home is not set
Browse files Browse the repository at this point in the history
  • Loading branch information
RanVaknin authored and skmcgrail committed Aug 12, 2022
1 parent 0ba2869 commit 1c762a4
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions config/shared_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"io"
"io/ioutil"
"os"
"os/user"
"path/filepath"
"strings"
"time"
Expand Down Expand Up @@ -1149,8 +1150,18 @@ func (e CredentialRequiresARNError) Error() string {

func userHomeDir() string {
// Ignore errors since we only care about Windows and *nix.
homedir, _ := os.UserHomeDir()
return homedir
home, _ := os.UserHomeDir()

if len(home) > 0 {
return home
}

currUser, _ := user.Current()
if currUser != nil {
home = currUser.HomeDir
}

return home
}

func oneOrNone(bs ...bool) bool {
Expand Down

0 comments on commit 1c762a4

Please sign in to comment.