The substring expansion ${parameter:offset:length} is a bashism and does
not work when /bin/sh points to a shell other than bash, e.g. on Ubuntu.
This commit replaces this expansion with a call to awk, inspired by the
solution at:
https://wiki.ubuntu.com/DashAsBinSh