diff --git a/src/commands/git_secret_hide.sh b/src/commands/git_secret_hide.sh index cb1760d5..9ade92b7 100644 --- a/src/commands/git_secret_hide.sh +++ b/src/commands/git_secret_hide.sh @@ -161,6 +161,10 @@ function hide { # shellcheck disable=2086 $gpg_local --use-agent --yes --trust-model=always --encrypt \ $recipients -o "$output_path" "$input_path" > /dev/null 2>&1 + local exit_code=$? + if [[ "$exit_code" -ne 0 ]]; then + _abort "problem encrypting file with gpg: exit code $exit_code" + fi # If -m option was provided, it will update unencrypted file hash local key="$filename" local hash="$file_hash" diff --git a/src/commands/git_secret_killperson.sh b/src/commands/git_secret_killperson.sh index 0d637583..4050def2 100644 --- a/src/commands/git_secret_killperson.sh +++ b/src/commands/git_secret_killperson.sh @@ -28,9 +28,13 @@ function killperson { # Getting the local `gpg` command: local gpg_local gpg_local=$(_get_gpg_local) - +t for email in "${emails[@]}"; do $gpg_local --batch --yes --delete-key "$email" + local exit_code=$? + if [[ "$exit_code" -ne 0 ]]; then + _abort "problem deleting key with gpg: exit code $exit_code" + fi done echo 'removed keys.' diff --git a/src/commands/git_secret_tell.sh b/src/commands/git_secret_tell.sh index bb0e5db1..911f0866 100644 --- a/src/commands/git_secret_tell.sh +++ b/src/commands/git_secret_tell.sh @@ -11,6 +11,10 @@ function get_gpg_key_count { local gpg_local gpg_local=$(_get_gpg_local) $gpg_local --list-public-keys --with-colon | gawk "$AWK_GPG_KEY_CNT" + local exit_code=$? + if [[ "$exit_code" -ne 0 ]]; then + _abort "problem counting keys with gpg: exit code $exit_code" + fi } function tell { @@ -68,12 +72,18 @@ function tell { # shellcheck disable=2154 local keyfile="$filename" + local exit_code if [[ -z "$homedir" ]]; then $SECRETS_GPG_COMMAND --export -a "$email" > "$keyfile" + exit_code=$? else # It means that homedir is set as an extra argument via `-d`: $SECRETS_GPG_COMMAND --no-permission-warning --homedir="$homedir" \ --export -a "$email" > "$keyfile" + exit_code=$? + fi + if [[ "$exit_code" -ne 0 ]]; then + _abort "problem exporting public key for '$email' with gpg: exit code $exit_code" fi if [[ ! -s "$keyfile" ]]; then @@ -84,6 +94,10 @@ function tell { local gpg_local gpg_local=$(_get_gpg_local) $gpg_local --import "$keyfile" > /dev/null 2>&1 + exit_code=$? + if [[ "$exit_code" -ne 0 ]]; then + _abort "problem importing public key with gpg: exit code $exit_code" + fi done echo "done. ${emails[*]} added as someone who know(s) the secret."