FiloSottile / age

A simple, modern and secure encryption tool (and Go library) with small explicit keys, no config options, and UNIX-style composability.
https://age-encryption.org
BSD 3-Clause "New" or "Revised" License
16.9k stars 495 forks source link

UX: `age -d -identity -` should read from stdin #143

Closed dsprenkels closed 3 years ago

dsprenkels commented 3 years ago

What were you trying to do

I was testing my backups, and I wanted to decrypt a file using some identity. I just indented to copy paste the identity into stdin. I expected this to work:

# Should dump the first couple of lines of this backup file
age --decrypt --identity - backup_file.age | head

Here, I expected age to follow the general Linux convention that - usually means standard input/output.

What happened

age tried to read the file from a (nonexistent) literal file -. I solved this easily:

# Should dump the first couple of lines of this backup file
age --decrypt --identity /dev/stdin backup_file.age | head
23:48:35 1d [daan@roku:/srv/katarastorage/private/backup/suki_backup] $ age --decrypt --identity - backup_file.age
Error: failed to open file: open -: no such file or directory
[ Did age not do what you expected? Could an error be more useful? Tell us: https://filippo.io/age/report ]
23:48:35 1d [daan@roku:/srv/katarastorage/private/backup/suki_backup] $ age --decrypt --identity /dev/stdin backup_file.age
[PASTE OF SECRET KEY]
[^D]
[backup contents printed by age]

I would like to fix this bug myself, is possible! :)