github.com/StackExchange/blackbox/v2@v2.0.1-0.20220331193400-d84e904973ab/bin/blackbox_edit (about) 1 #!/usr/bin/env bash 2 3 # 4 # blackbox_edit -- Decrypt a file temporarily for edition, then re-encrypts it again 5 # 6 set -e 7 source "${0%/*}/_blackbox_common.sh" 8 9 for param in "$@" ; do 10 11 unencrypted_file=$(get_unencrypted_filename "$param") 12 encrypted_file=$(get_encrypted_filename "$param") 13 14 echo >&2 ========== PLAINFILE '"'$unencrypted_file'"' 15 echo >&2 ========== ENCRYPTED '"'$encrypted_file'"' 16 17 if ! is_on_cryptlist "$encrypted_file" && ! is_on_cryptlist "$unencrypted_file" ; then 18 read -r -p "Encrypt file $param? (y/n) " ans 19 case "$ans" in 20 y* | Y*) 21 "${BLACKBOX_HOME}/blackbox_register_new_file" "$unencrypted_file" 22 ;; 23 *) 24 echo >&2 'Skipping...' 25 continue 26 ;; 27 esac 28 fi 29 "${BLACKBOX_HOME}/blackbox_edit_start" "$unencrypted_file" 30 $EDITOR "$(get_unencrypted_filename "$unencrypted_file")" 31 "${BLACKBOX_HOME}/blackbox_edit_end" "$unencrypted_file" 32 33 done