Files
blackbox/bin/blackbox_edit
Jon Warbrick b35c09609b Avoid needing blackbox scripts on $PATH
blackbox_edit and blackbox_cat use other blackbox scripts internally,
but assume that they will be found on $PATH. In testing it's useful to
be able to run these scripts by pathname without first putting them on
$PATH, and all the other scripts work just fine in these circumstances.

This edit fixes this by prefixing all references to other scripts in
blackbox_edit and blackbox_cat with ${blackbox_home}, which is conveniently
set as part of sourcing _blackbox_common.sh.
2015-03-08 19:59:55 +00:00

28 lines
784 B
Bash
Executable File

#!/usr/bin/env bash
#
# blackbox_edit.sh -- Decrypt a file temporarily for edition, then re-encrypts it again
#
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")
if ! is_on_cryptlist "$param" && ! is_on_cryptlist "$unencrypted_file" ; then
read -r -p "Encrypt file $param? (y/n) " ans
case "$ans" in
y* | Y*)
"${blackbox_home}/blackbox_register_new_file" "$param"
;;
*)
echo 'Skipping...'
continue
;;
esac
fi
"${blackbox_home}/blackbox_edit_start" "$param"
"$EDITOR" "$(get_unencrypted_filename "$param")"
"${blackbox_home}/blackbox_edit_end" "$param"
done