2014-09-04 11:29:23 -03:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# blackbox_edit.sh -- Decrypt a file temporarily for edition, then re-encrypts it again
|
|
|
|
|
#
|
2014-09-08 20:25:38 +00:00
|
|
|
set -e
|
2015-01-13 14:42:58 -05:00
|
|
|
blackbox_home=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
|
2015-02-27 01:01:48 +07:00
|
|
|
source "${blackbox_home}/_blackbox_common.sh"
|
2014-09-04 11:29:23 -03:00
|
|
|
|
|
|
|
|
for param in """$@""" ; do
|
2014-10-19 20:55:47 -07:00
|
|
|
unencrypted_file=$(get_unencrypted_filename "$param")
|
2015-01-26 13:45:44 -05:00
|
|
|
if ! is_on_cryptlist "$param" && ! is_on_cryptlist "$unencrypted_file" ; then
|
2014-11-05 16:48:10 +00:00
|
|
|
read -r -p "Encrypt file $param? (y/n) " ans
|
2014-09-09 20:32:48 +00:00
|
|
|
case "$ans" in
|
|
|
|
|
y* | Y*)
|
2015-03-08 19:59:55 +00:00
|
|
|
"${blackbox_home}/blackbox_register_new_file" "$param"
|
2014-09-09 20:32:48 +00:00
|
|
|
;;
|
|
|
|
|
*)
|
|
|
|
|
echo 'Skipping...'
|
|
|
|
|
continue
|
|
|
|
|
;;
|
|
|
|
|
esac
|
2014-09-04 11:29:23 -03:00
|
|
|
fi
|
2015-03-08 19:59:55 +00:00
|
|
|
"${blackbox_home}/blackbox_edit_start" "$param"
|
2015-02-27 01:01:48 +07:00
|
|
|
"$EDITOR" "$(get_unencrypted_filename "$param")"
|
2015-03-08 19:59:55 +00:00
|
|
|
"${blackbox_home}/blackbox_edit_end" "$param"
|
2014-09-04 11:29:23 -03:00
|
|
|
done
|