From 0e5fdf6fa30b01919444c29fde55f415181a7e08 Mon Sep 17 00:00:00 2001 From: Bryan Roberts Date: Sat, 14 Feb 2015 20:00:34 -0500 Subject: [PATCH 1/6] Added EDITOR default to blackbox_edit; Created blackbox_view --- bin/blackbox_edit | 1 + bin/blackbox_view | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100755 bin/blackbox_view diff --git a/bin/blackbox_edit b/bin/blackbox_edit index ea733ac..8fdba99 100755 --- a/bin/blackbox_edit +++ b/bin/blackbox_edit @@ -4,6 +4,7 @@ # blackbox_edit.sh -- Decrypt a file temporarily for edition, then re-encrypts it again # set -e +[ -z $EDITOR ] && EDITOR="vi" blackbox_home=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) source ${blackbox_home}/_blackbox_common.sh diff --git a/bin/blackbox_view b/bin/blackbox_view new file mode 100755 index 0000000..09b64dd --- /dev/null +++ b/bin/blackbox_view @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +# +# blackbox_edit.sh -- Decrypt a file temporarily for edition, then re-encrypts it again +# +set -e +[ -z $EDITOR ] && EDITOR="vi" +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_register_new_file "$param" + ;; + *) + echo 'Skipping...' + continue + ;; + esac + fi + blackbox_edit_start "$param" + $EDITOR $(get_unencrypted_filename $param) + rm -f "$param" +done From a95a5ef629e22ad718ec81b4ea7da900b9787f5a Mon Sep 17 00:00:00 2001 From: Bryan Roberts Date: Sun, 15 Feb 2015 02:22:41 -0500 Subject: [PATCH 2/6] Fixed argument for deletion --- bin/blackbox_view | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/blackbox_view b/bin/blackbox_view index 09b64dd..1d17465 100755 --- a/bin/blackbox_view +++ b/bin/blackbox_view @@ -24,5 +24,6 @@ for param in """$@""" ; do fi blackbox_edit_start "$param" $EDITOR $(get_unencrypted_filename $param) - rm -f "$param" + unencrypted_file=$(get_unencrypted_filename "$param") + rm -f "$unencrypted_file" done From 9b5af9f85c324fc71884f9f33605201cb1b9dd1b Mon Sep 17 00:00:00 2001 From: Bryan Roberts Date: Sun, 15 Feb 2015 02:35:03 -0500 Subject: [PATCH 3/6] Added EDITOR default to _blackbox_common.sh --- bin/_blackbox_common.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/bin/_blackbox_common.sh b/bin/_blackbox_common.sh index eaf4bd3..b886ad8 100755 --- a/bin/_blackbox_common.sh +++ b/bin/_blackbox_common.sh @@ -11,6 +11,11 @@ # Where in the VCS repo should the blackbox data be found? : ${BLACKBOXDATA:=keyrings/live} ; # If BLACKBOXDATA not set, set it. + + +# If $EDITOR is not set, set it to "vi": +: ${EDITOR:-vi} ; + # Outputs a string that is the base directory of this VCS repo. # By side-effect, sets the variable VCS_TYPE to either 'git', 'hg', From e5028b0fdbc8f468520774ec4423529f7a49b512 Mon Sep 17 00:00:00 2001 From: Bryan Roberts Date: Sun, 15 Feb 2015 02:36:11 -0500 Subject: [PATCH 4/6] Removed blackbox_view since blackbox_cat already exists --- bin/blackbox_view | 29 ----------------------------- 1 file changed, 29 deletions(-) delete mode 100755 bin/blackbox_view diff --git a/bin/blackbox_view b/bin/blackbox_view deleted file mode 100755 index 1d17465..0000000 --- a/bin/blackbox_view +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env bash - -# -# blackbox_edit.sh -- Decrypt a file temporarily for edition, then re-encrypts it again -# -set -e -[ -z $EDITOR ] && EDITOR="vi" -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_register_new_file "$param" - ;; - *) - echo 'Skipping...' - continue - ;; - esac - fi - blackbox_edit_start "$param" - $EDITOR $(get_unencrypted_filename $param) - unencrypted_file=$(get_unencrypted_filename "$param") - rm -f "$unencrypted_file" -done From d4fd6cf8ed6de474a22359be19b50af601582ba8 Mon Sep 17 00:00:00 2001 From: Bryan Roberts Date: Sun, 15 Feb 2015 11:40:00 -0500 Subject: [PATCH 5/6] Removed check for EDITOR from blackbox_edit --- bin/blackbox_edit | 1 - 1 file changed, 1 deletion(-) diff --git a/bin/blackbox_edit b/bin/blackbox_edit index 8fdba99..ea733ac 100755 --- a/bin/blackbox_edit +++ b/bin/blackbox_edit @@ -4,7 +4,6 @@ # blackbox_edit.sh -- Decrypt a file temporarily for edition, then re-encrypts it again # set -e -[ -z $EDITOR ] && EDITOR="vi" blackbox_home=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) source ${blackbox_home}/_blackbox_common.sh From 63b5dc9de46e86ae975ea3e31a052844e3034b0a Mon Sep 17 00:00:00 2001 From: Bryan Roberts Date: Sun, 15 Feb 2015 11:52:34 -0500 Subject: [PATCH 6/6] Fixed parameter expansion in _blackbox_common.sh for EDITOR --- bin/_blackbox_common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/_blackbox_common.sh b/bin/_blackbox_common.sh index b886ad8..9915c8d 100755 --- a/bin/_blackbox_common.sh +++ b/bin/_blackbox_common.sh @@ -14,7 +14,7 @@ # If $EDITOR is not set, set it to "vi": -: ${EDITOR:-vi} ; +: ${EDITOR:=vi} ; # Outputs a string that is the base directory of this VCS repo.