--- /dev/null
+#!/usr/bin/env bash
+# Desc: A script that outputs a list of GPG signatures from git log output
+# Usage: get_gpgkey_from_gitlog.sh [dir]
+# Input: arg1: directory
+# Output: stdout: newline-delimited list of 40-char GPG fingerprints
+
+declare -g buffer;
+
+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_args() {
+ # Desc: Check arguments
+ if [[ $# -ne 1 ]]; then die "FATAL:Incorrect number of arguments:$#"; fi;
+ if [[ ! -d $1 ]]; then die "Not a directory:$1"; fi;
+ return 0;
+}; # check args
+fill_buffer() {
+ # Input: arg1: git dir
+ # Output: var: $buffer: newline-delimited list of gpg fingerprints
+ pushd "$1" 1>/dev/random || die "FATAL:Failed to change directory:$1";
+ buffer="$(git log --show-signature 2>&1)";
+ yell "DEBUG:Buffer has $(wc -l < <(printf "%s" "$buffer")) lines.";
+ buffer="$(grep -E -- "^gpg:" < <( printf "%s" "$buffer" ) )";
+ yell "DEBUG:Buffer has $(wc -l < <(printf "%s" "$buffer")) lines.";
+ buffer="$(grep -Eo "([0-9A-F]){40}" < <( printf "%s" "$buffer" ) )";
+ yell "DEBUG:Buffer has $(wc -l < <(printf "%s" "$buffer")) lines.";
+ buffer="$(sort -u < <( printf "%s" "$buffer" ))";
+ yell "DEBUG:Buffer has $(wc -l < <(printf "%s" "$buffer")) lines.";
+ popd 1>/dev/random || die "FATAL:Failed to popd.";
+}; # fill buffer with git gpg lines
+main() {
+ check_args "$@";
+ fill_buffer "$1";
+ printf "%s\n" "$buffer";
+ return 0;
+};
+
+main "$@";
+
+# git log --show-signature 2>&1 | grep -E -- "^gpg:" | grep -Eo "([0-9A-F]){40}" | sort -u