caio-ribeiro-pereira/gzipme — pull request #1 by jylauril (2013-07-04 12:14:43+00:00)
Title: Added safety checks for file existence and now unlinks generated gz file if it failed

The problem was that when you run the gzipme with erroneous file path, it still generated an empty .gz file. This commit fixes that by first checking the existence of the file we're trying to gzip and exiting early if it doesn't.

However, there's also a chance that the file did exist, but there was other kind of error (like no read access, no space on disk for the output file content, buffering error, etc.), so it might still create the output file. This commit fixes that in the catch of the error by checking if we created the output file (and also that it wasn't meant to overwrite the existing file) and deleting it.