Skip to content

Commit

Permalink
Adding error message when sock file exists
Browse files Browse the repository at this point in the history
  • Loading branch information
Artem authored and benpye committed Nov 21, 2020
1 parent e52845a commit 18e270c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,14 +239,16 @@ func main() {
}()

if *unixSocket != "" {
if *force {
// If the socket file already exists then unlink it
_, err := os.Stat(*unixSocket)
if err == nil || !os.IsNotExist(err) {
_, err := os.Stat(*unixSocket)
if err == nil || !os.IsNotExist(err) {
if *force {
// If the socket file already exists then unlink it
err = syscall.Unlink(*unixSocket)
if err != nil {
log.Fatalf("Failed to unlink socket %s, error '%s'\n", *unixSocket, err)
}
} else {
log.Fatalf("Error: the SSH_AUTH_SOCK file already exists. Please delete it manually or use --force option.")
}
}

Expand Down

0 comments on commit 18e270c

Please sign in to comment.