Skip to content

Commit 32defca

Browse files
committed
get: Cope with an empty ssh-agent
ssh-add -L returns 1 if the agent is empty and 2 if the agent could not be reached. Ignore the first case, as there is nothing to remove.
1 parent b719336 commit 32defca

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

cmd/get.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ var getCmd = &cobra.Command{
116116
}
117117

118118
stdout, err = exec.Command("ssh-add", "-L").Output()
119-
if err != nil {
119+
if exiterr, ok := err.(*exec.ExitError); (ok && exiterr.ExitCode() == 2) || (!ok && err != nil) {
120120
return fmt.Errorf("could not query the SSH agent for its keys: %w", err)
121121
}
122122
var remove bytes.Buffer

0 commit comments

Comments
 (0)