BIG CHANGES:
* Command no longer need to be run from the base directory of the repo. * blackbox_edit now asks "are you sure?" and is greatly simplified. _blackbox_common.sh: * add_filename_to_cryptlist now accepts paths relative to cwd. * fail_if_not_on_cryptlist now accepts paths relative to cwd. * new function: vcs_relative_path reports a path to the file relative to the REPOBASE. * new function: is_on_cryptlist plus... * Some minor performance enhancesments and cleanups. * confidence_test.sh now tests some commands while not in REPOBASE.
This commit is contained in:
@@ -3,33 +3,24 @@
|
||||
#
|
||||
# blackbox_edit.sh -- Decrypt a file temporarily for edition, then re-encrypts it again
|
||||
#
|
||||
|
||||
set -e
|
||||
. _blackbox_common.sh
|
||||
set -x
|
||||
|
||||
for param in """$@""" ; do
|
||||
unencrypted_file=$(mktemp)
|
||||
encrypted_file=$(get_encrypted_filename "$param")
|
||||
echo ========== 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"
|
||||
if ! is_on_cryptlist "$param" ; then
|
||||
read -p "Encrypt file $param? (y/n) " ans
|
||||
case "$ans" in
|
||||
y* | Y*)
|
||||
blackbox_register_new_file "$param"
|
||||
;;
|
||||
*)
|
||||
echo 'Skipping...'
|
||||
continue
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
if [[ -f "$unencrypted_file" ]]; then
|
||||
echo SKIPPING: "$1" "Will not overwrite non-empty files."
|
||||
continue
|
||||
fi
|
||||
|
||||
prepare_keychain
|
||||
decrypt_file "$encrypted_file" "$unencrypted_file"
|
||||
blackbox_edit_start "$param"
|
||||
$EDITOR $unencrypted_file
|
||||
|
||||
encrypt_file "$unencrypted_file" "$encrypted_file"
|
||||
shred_file "$unencrypted_file"
|
||||
|
||||
echo "========== UPDATED ${encrypted_file}"
|
||||
echo "Likely next step:"
|
||||
echo " git commit -m\"${encrypted_file} updated\" $encrypted_file"
|
||||
blackbox_edit_end "$param"
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user