in reply to How to test if a file is gzipped or not

Why don't you just catch the error from gunzipping and try proceeding otherwise?

If that's not enough, Gzip files start with a header including a magic number (1f 8b)

You could also look if available uncompress tools have a check option to validate if it's a legit format.°

Edit

°) See documentation for gunzip

Cheers Rolf
(addicted to the Perl Programming Language :)
see Wikisyntax for the Monastery