Skip to content

Commit

Permalink
cmd/age: fallback to stdin if /dev/tty cannot be opened (#414)
Browse files Browse the repository at this point in the history
  • Loading branch information
brandsimon authored May 4, 2022
1 parent e8771b6 commit ac31f5c
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions cmd/age/encrypted_keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,7 @@ func readPassphrase(prompt string) ([]byte, error) {
return nil, err
}
defer out.Close()
} else if _, err := os.Stat("/dev/tty"); err == nil {
tty, err := os.OpenFile("/dev/tty", os.O_RDWR, 0)
if err != nil {
return nil, err
}
} else if tty, err := os.OpenFile("/dev/tty", os.O_RDWR, 0); err == nil {
defer tty.Close()
in, out = tty, tty
} else {
Expand Down

0 comments on commit ac31f5c

Please sign in to comment.