keygeneration: fix some portability aspects

The "function" keyword is not portable -- use the normal function style.

The awk command uses a non-portable regex (the word anchor \>).  Rework
it to avoid regexes entirely.

BUG=chromium:475101
TEST=keyset_version_check.sh works on a POSIX system
BRANCH=None

Change-Id: I5446f63aa9181d06da1898aafb8fab17f5042989
Reviewed-on: https://chromium-review.googlesource.com/296562
Commit-Ready: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
Reviewed-by: David Riley <davidriley@chromium.org>
diff --git a/scripts/keygeneration/common.sh b/scripts/keygeneration/common.sh
index b15a2f2..07a7b2c 100644
--- a/scripts/keygeneration/common.sh
+++ b/scripts/keygeneration/common.sh
@@ -54,7 +54,7 @@
 # likely to cause problems than just keeping an eye out for any differences. If
 # you feel the need to change this file, check the history of that other file
 # to see what may need updating here too.
-function make_pair {
+make_pair() {
   local base=$1
   local alg=$2
   local key_version=${3:-1}
@@ -94,7 +94,7 @@
 #   0x02  Developer switch on
 #   0x04  Not recovery mode
 #   0x08  Recovery mode
-function make_keyblock {
+make_keyblock() {
   local base=$1
   local flags=$2
   local pubkey=$3
@@ -120,7 +120,9 @@
 
 # ARGS: <VERSION_TYPE> [VERSION_FILE]
 get_version() {
-  awk -F= '/^'$1'\>/ { print $NF }' "${2:-${VERSION_FILE}}"
+  local key="$1"
+  local file="${2:-${VERSION_FILE}}"
+  awk -F= -vkey="${key}" '$1 == key { print $NF }' "${file}"
 }
 
 # Loads the current versions prints them to stdout and sets the global version