chore(unitproc):Rename script
authorSteven Baltakatei Sandoval <baltakatei@gmail.com>
Wed, 9 Mar 2022 14:45:08 +0000 (14:45 +0000)
committerSteven Baltakatei Sandoval <baltakatei@gmail.com>
Wed, 9 Mar 2022 14:45:08 +0000 (14:45 +0000)
- Note: Renaming `bktemp-check_gpg_fingerprint` to
  `bktemp-check_resembles_gpg_fingerprint` since the script doesn't
  actually use gpg to check the fingerprint.

unitproc/bktemp-check_resembles_gpg_fingerprint [moved from unitproc/bktemp-check_gpg_fingerprint with 55% similarity]

similarity index 55%
rename from unitproc/bktemp-check_gpg_fingerprint
rename to unitproc/bktemp-check_resembles_gpg_fingerprint
index e2af7686b0bb694a5f6bf0798f4d9e6f0c3f397d..ff5a39fe851a5f3dbf7a9b1dd7092c39c1a2fa3d 100644 (file)
@@ -3,9 +3,9 @@
 yell() { echo "$0: $*" >&2; } # print script path and all args to stderr
 die() { yell "$*"; exit 111; } # same as yell() but non-zero exit status
 try() { "$@" || die "cannot $*"; } # runs args as command, reports args if command fails
-check_gpg_fingerprint() {
+check_resembles_gpg_fingerprint() {
     # Desc: Checks if input string looks like gpg fingerprint
-    # Usage: check_gpg_fingerprint arg1
+    # Usage: check_resembles_gpg_fingerprint arg1
     # Input: arg1: string
     # Output: exit code: 0 if arg1 is fingerprint, 1 otherwise
     # Depends: yell(), die(), try()
@@ -22,7 +22,7 @@ check_gpg_fingerprint() {
     ## Trim leading `0x`
     pattern1="(0x)(.*)";
     if [[ $input =~ $pattern1 ]]; then
-       input="$(echo "$input" | sed 's/^..//')";
+       input="${input:2}";
        #yell "DEBUG:input:$input";
     fi;
     
@@ -47,7 +47,42 @@ check_gpg_fingerprint() {
 
 # test code
 myVar="0xdc3469c9";
-if check_gpg_fingerprint "$myVar"; then
+if check_resembles_gpg_fingerprint "$myVar"; then
+    yell "Looks like a gpg fingerprint:$myVar";
+else
+    yell "Doesn't look like a gpg fingerprint:$myVar";
+fi;
+
+myVar="69B4C4CDC628F8F9";
+if check_resembles_gpg_fingerprint "$myVar"; then
+    yell "Looks like a gpg fingerprint:$myVar";
+else
+    yell "Doesn't look like a gpg fingerprint:$myVar";
+fi;
+
+myVar="26646D99CBAEC9B81982EF6029D9EE6B1FC730C1";
+if check_resembles_gpg_fingerprint "$myVar"; then
+    yell "Looks like a gpg fingerprint:$myVar";
+else
+    yell "Doesn't look like a gpg fingerprint:$myVar";
+fi;
+
+myVar="deadbeef";
+if check_resembles_gpg_fingerprint "$myVar"; then
+    yell "Looks like a gpg fingerprint:$myVar";
+else
+    yell "Doesn't look like a gpg fingerprint:$myVar";
+fi;
+
+myVar="foobar";
+if check_resembles_gpg_fingerprint "$myVar"; then
+    yell "Looks like a gpg fingerprint:$myVar";
+else
+    yell "Doesn't look like a gpg fingerprint:$myVar";
+fi;
+
+myVar="zzzzzzzz";
+if check_resembles_gpg_fingerprint "$myVar"; then
     yell "Looks like a gpg fingerprint:$myVar";
 else
     yell "Doesn't look like a gpg fingerprint:$myVar";