#84 Update gpgverify
Opened 4 years ago by duck5. Modified 2 years ago
rpms/ duck5/redhat-rpm-config master  into  rawhide

file modified
+16 -15
@@ -12,6 +12,7 @@ 

  # modified is included with the above copyright notice.

  

  

+ 

  function print_help {

      cat <<'EOF'

  Usage: gpgverify --keyring=<pathname> --signature=<pathname> --data=<pathname>
@@ -35,16 +36,16 @@ 

  

  fatal_error() {

      message="$1"  # an error message

-     status=$2     # a number to use as the exit code

+     status="$2"     # a number to use as the exit code

      echo "gpgverify: $message" >&2

-     exit $status

+     exit "$status"

  }

  

  

  require_parameter() {

      term="$1"   # a term for a required parameter

      value="$2"  # Complain and terminate if this value is empty.

-     if test -z "${value}" ; then

+     if [[ -z "$value" ]] ; then

          fatal_error "No ${term} was provided." 2

      fi

  }
@@ -52,9 +53,9 @@ 

  

  check_status() {

      action="$1"  # a string that describes the action that was attempted

-     status=$2    # the exit code of the command

-     if test $status -ne 0 ; then

-         fatal_error "$action failed." $status

+     status="$2"    # the exit code of the command

+     if [[ $status -ne 0 ]] ; then

+         fatal_error "$action failed." "$status"

      fi

  }

  
@@ -65,21 +66,21 @@ 

  data=

  for parameter in "$@" ; do

      case "${parameter}" in

-         (--help)

+         --help)

              print_help

              exit

              ;;

-         (--keyring=*)

+         --keyring=*)

              keyring="${parameter#*=}"

              ;;

-         (--signature=*)

+         --signature=*)

              signature="${parameter#*=}"

              ;;

-         (--data=*)

+         --data=*)

              data="${parameter#*=}"

              ;;

-         (*)

-             fatal_error "Unknown parameter: \"${parameter}\"" 2

+         *)

+             fatal_error 'Unknown parameter:' "$parameter" 2

fatal_error 'Unknown parameter:' "$parameter" 2

This drops the quoted in output. Please skip this chunk.

              ;;

      esac

  done
@@ -89,17 +90,17 @@ 

  

  # Make a temporary working directory.

  workdir="$(mktemp --directory)"

- check_status 'Making a temporary directory' $?

+ check_status 'Making a temporary directory' "$?"

  workring="${workdir}/keyring.gpg"

  

  # Decode any ASCII armor on the keyring. This is harmless if the keyring isn't

  # ASCII-armored.

  gpg2 --homedir="${workdir}" --yes --output="${workring}" --dearmor "${keyring}"

- check_status 'Decoding the keyring' $?

+ check_status 'Decoding the keyring' "$?"

  

  # Verify the signature using the decoded keyring.

  gpgv2 --homedir="${workdir}" --keyring="${workring}" "${signature}" "${data}"

- check_status 'Signature verification' $?

+ check_status 'Signature verification' "$?"

  

  # (--homedir isn't actually necessary. --dearmor processes only the input file,

  # and if --keyring is used and contains a slash, then gpgv2 uses only that

Updating bash syntax: adding quotes, changing test to [[, add an exit code, etc.

It would be nice to write why it is needed.

right. is there some question in this conversation?

@duck5 @ignatenkobrain is asking for you to add information for why this change is needed into the commit message.

ok. I'm learning how to do this by reading up on git. thx :-)

fatal_error 'Unknown parameter:' "$parameter" 2

This drops the quoted in output. Please skip this chunk.

This is a nice cleanup, except for the one spot mentioned above. @duck5 can you do an update please?

Metadata