This makes the beginning of all files the same and a little simpler.
`${0%/*}` turns "/home/user/repository/bin/blackbox_edit" into
"/home/user/repository/bin", exactly like basename but without eating a
process.
Because other scripts needed `$blackbox_home` I made this into a
standardard variable that's always available.
This also loads _stack_lib.sh always because _blackbox_common.sh
requires it.
27 lines
704 B
Bash
Executable File
27 lines
704 B
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
#
|
|
# blackbox_edit -- Decrypt a file temporarily for edition, then re-encrypts it again
|
|
#
|
|
set -e
|
|
source "${0%/*}/_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
|