Files
blackbox/bin/blackbox_edit_start

37 lines
883 B
Plaintext
Raw Permalink Normal View History

#!/usr/bin/env bash
2014-07-07 20:30:16 -04:00
#
# blackbox_edit_start -- Decrypt a file for editing.
2014-07-07 20:30:16 -04:00
#
2014-09-08 20:25:38 +00:00
set -e
source "${0%/*}/_blackbox_common.sh"
2014-07-07 20:30:16 -04:00
if [ $# -eq 0 ]; then
echo >&2 "Please provide at least one file to start editing"
exit 1
fi
2015-06-12 13:27:42 -05:00
for param in "$@" ; do
2014-07-07 20:30:16 -04:00
unencrypted_file=$(get_unencrypted_filename "$param")
encrypted_file=$(get_encrypted_filename "$param")
echo >&2 ========== PLAINFILE '"'$unencrypted_file'"'
2014-07-07 20:30:16 -04:00
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."
2014-07-07 20:30:16 -04:00
continue
fi
prepare_keychain
# FIXME(tlim): prepare_keychain only needs to run once, outside of the loop.
2014-07-07 20:30:16 -04:00
decrypt_file "$encrypted_file" "$unencrypted_file"
2014-07-07 20:30:16 -04:00
done