Files
blackbox/bin/blackbox_edit_start
2015-06-12 13:27:42 -05:00

29 lines
776 B
Bash
Executable File

#!/usr/bin/env bash
#
# blackbox_edit_start -- Decrypt a file for editing.
#
set -e
blackbox_home=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
source "${blackbox_home}/_blackbox_common.sh"
for param in "$@" ; do
unencrypted_file=$(get_unencrypted_filename "$param")
encrypted_file=$(get_encrypted_filename "$param")
echo >&2 ========== PLAINFILE '"'$unencrypted_file'"'
fail_if_not_on_cryptlist "$unencrypted_file"
fail_if_not_exists "$encrypted_file" "This should not happen."
if [[ ! -s "$unencrypted_file" ]]; then
rm -f "$unencrypted_file"
fi
if [[ -f "$unencrypted_file" ]]; then
echo >&2 SKIPPING: "$1" "Will not overwrite non-empty files."
continue
fi
prepare_keychain
decrypt_file "$encrypted_file" "$unencrypted_file"
done