IANA Bash Guru but...
Here's some tweaks that appear to fix the following issue with serialnumber:

/opt/utilities/bin/serialnumber
/opt/utilities/bin/serialnumber: line 11: local: can only be used in a function

Standard disclaimer applies, works on my block ;)
Take 2 with less truncation of lines...