Other Safely rename files to their SHA1 sum + ext on FreeBSD 11

I have a collection of files with external origin which had bad names. The worst characters that they contained were some UTF-8 characters and the single quotation mark. Aside from these characters, there were other unwanted characters such as spaces in the file names. For this collection of files, because I use the metadata that is inside of the files to organize them, I don't care so much what the files are called, as long as they don't contain non-ASCII, non-printable or other troublesome characters.

I wrote a script for FreeBSD 11 to safely rename such files to be named by their own SHA1 hash sum plus their original extension. (Files with bad characters in extension are made extension-less.)

Here is the script: https://github.com/eriknstr/utils/blob/master/shaname.sh

I have commented the script in detail so that readers may quickly see what's going on and which assumptions are made, so that they may determine whether the script is appropriate for their use-case.

I reiterate that the script was written for FreeBSD 11 and should not be used on platforms with commands that have incompatible arguments.

The script is released under the ISC license.

Pull requests are welcome.