Converted from the original version for the BASH script. Very easy and
minor changes.