Hey FRIGN, I'm glad you quoted! I do have a couple questions and discussion points I'd value your feedback on.
Why all the extraneous semicolons? I see this a lot in awk, too. I think it tends to be a reflex for C programmers. Why not quote "$ret"? You don't have control over the environment in which the user will run the script. I know it sounds stupid, but I have literally seen a script run in a case where IFS=0 and if [ $? -ne 0 ] broke. And it was a legitimate usage. And the following purely style questions: What are your thoughts on FORMAT=$(file -ib "$TMP") FORMAT=${FORMAT%;*} instead of using the file | cut? I tend towards using shell parameter expansion instead of piping. I think I started to do so in order to save the fork and pipe, but now it just comes more naturally to me. I still highly recommend not using all cap variables. I'm not sure where the trend started, I don't see it in any other language (does pop up in makefiles).