github.com/StackExchange/blackbox/v2@v2.0.1-0.20220331193400-d84e904973ab/bin/blackbox_edit_end (about) 1 #!/usr/bin/env bash 2 3 # 4 # blackbox_edit_end -- Re-encrypt file after edits. 5 # 6 7 set -e 8 source "${0%/*}/_blackbox_common.sh" 9 10 next_steps=() 11 12 if [ $# -eq 0 ]; then 13 echo >&2 "Please provide at least one file for which editing has finished" 14 exit 1 15 fi 16 17 for param in "$@" ; do 18 19 unencrypted_file=$(get_unencrypted_filename "$param") 20 encrypted_file=$(get_encrypted_filename "$param") 21 22 echo >&2 ========== PLAINFILE '"'$unencrypted_file'"' 23 echo >&2 ========== ENCRYPTED '"'$encrypted_file'"' 24 25 fail_if_not_on_cryptlist "$unencrypted_file" 26 fail_if_not_exists "$unencrypted_file" "No unencrypted version to encrypt!" 27 fail_if_keychain_has_secrets 28 29 encrypt_file "$unencrypted_file" "$encrypted_file" 30 shred_file "$unencrypted_file" 31 echo >&2 ========== UPDATED '"'$encrypted_file'"' 32 next_steps+=( " $VCS_TYPE commit -m\"${encrypted_file} updated\" \"$encrypted_file\"" ) 33 34 done 35 36 echo >&2 "Likely next step:" 37 for x in "${next_steps[@]}" 38 do 39 echo >&2 "$x" 40 done