gpg doesn't fail on target file existing when decrypting

Andrew Flerchinger at
Wed Mar 11 21:15:20 CET 2009

I'm in windows trying to run gpg (GnuPG) 1.4.9 (Gpg4win 1.1.4) in batch
mode, completely non-interactive. I can encrypt a file like this:
gpg --passphrase **PASS** --trust-model always --batch --output
"test.txt.pgp" --sign --recipient **RECIP** --encrypt "test.txt"

and it runs fine. If I do it a second time and the output file exists, it
exits with a non-zero error code. Passing in --yes overwrites the file and
success is returned. So far, so good.

When I decrypt a file, I use a very similar command:

gpg --passphrase **PASS** --trust-model always --batch --output "test.txt"
--decrypt "test.txt.pgp"

It mostly works fine. If the output file doesn't exist, it creates it
properly. If it does exist and I add --yes, it overwrites it properly. My
problem is when I don't tell it to overwrite and the target exists, it looks
like it properly decrypted the file, except it does nothing. The return code
is still zero and the output looks exactly the same as when the file doesn't
exist and it creates it.

I'm trying to figure out if I'm doing something wrong, it's a bug, or if the
intended behavior is not the same between encryption and decryption. If I
remove --batch from either encrypt or decrypt, both prompt me for a
replacement file name. I was assuming both would fail given the option. Can
anyone shed some light on this for me?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/attachments/20090311/1143f254/attachment-0001.htm>

More information about the Gnupg-users mailing list