Mailing List Archive

Quit gracefully on wrong password
Hi,
I'm using GPG to decrypt an encrypted file. The command I'm using is the following:

$ gpg -a --decrypt --no-symkey-cache --batch --passphrase "correct_pw" --output file.txt file.txt.enc

This works fine when the password is correct. When I try using an incorrect password, however, gpg leaves me in a prompt waiting for further commands:

$ gpg -a --decrypt --no-symkey-cache --batch --passphrase "incorrect_pw" --output file.txt file.txt.enc
gpg: AES256.CFB encrypted data
gpg: encrypted with 1 passphrase
gpg: decryption failed: Bad session key
^C
gpg: signal Interrupt caught ... exiting

where I have to manually interrupt the process using ctrl + c.

So my question is: is there a way to just quit the program when the password is incorrect? I need to use this command inside a script which is supposed to be running in background, this behaviour would break the entire pipeline.

Thanks in advance.