From ae90dce106b8d3bd359d76e43af5bbe789954971 Mon Sep 17 00:00:00 2001 From: Vera Lewis Date: Sun, 31 Mar 2024 03:37:30 -0500 Subject: [PATCH] Fixed init committing before .gpg-id created; muted calls to gpg --- vns | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/vns b/vns index 158b51b..5e0eee6 100644 --- a/vns +++ b/vns @@ -77,14 +77,10 @@ vns_init () { echo -n '' > "${VNS_STORE}/.gpg-id" vns_reencrypt "$VNS_STORE" "$@" - else # Create a new VNS Store - git init "$VNS_STORE" - - # Make initial commit - vns_git add .gpg-id - vns_git commit -am "Initialized VNS Store" + git init "$VNS_STORE" >/dev/null + vns_report "Initialized new VNS store" fi @@ -93,6 +89,8 @@ vns_init () { for recipient in "$@"; do echo "$recipient" >> "${VNS_STORE}/.gpg-id" done + vns_git add .gpg-id >/dev/null + vns_git commit -am "Updated GPG recipients" >/dev/null } vns_reencrypt () { @@ -109,7 +107,7 @@ vns_reencrypt () { # Find all notes and re-encrypt them find "${VNS_STORE}" -name "*.gpg" | while read -r FILE; do\ - gpg --batch -d "$FILE" 2>/dev/null | gpg --batch "${GPG_RECIPS[@]}" -e -o "${FILE}_new".gpg >/dev/null 2>&1 + gpg --batch --decrypt "$FILE" 2>/dev/null | gpg --batch "${GPG_RECIPS[@]}" --encrypt --output "${FILE}_new".gpg >/dev/null 2>&1 mv "${FILE}_new.gpg" "$FILE"; done @@ -237,7 +235,7 @@ vns_create () { # Create empty note mkdir -p "$(dirname "$VNS_STORE/$1.gpg")" - vns_header "$(basename "$1")" | gpg --batch "$(vns_gpgid)" --encrypt -o "$VNS_STORE/$1.gpg" + vns_header "$(basename "$1")" | gpg --batch "$(vns_gpgid)" --encrypt -o "$VNS_STORE/$1.gpg" 2>/dev/null # Edit the note vim "$VNS_STORE/$1.gpg" @@ -352,10 +350,6 @@ vns_merge () { if [ -r "$VNS_STORE/$1.gpg" ]; then vns_raise "Output file already exists." 82; fi if [ ! -r "$VNS_STORE/$2.gpg" ]; then vns_raise "Could not read $2" 83; fi - #local GPG_OPTS=() - #for recip in $(gpg --list-only -v -d "${VNS_STORE}/$2.gpg" 2>&1 | awk '/public key is/{print $5}'); do - # GPG_OPTS=( "${GPG_OPTS[@]}" -r "$recip" ) - #done local -r NOTE_NAME="$1" local -r OUTPUT="${VNS_STORE}/${1}.gpg" shift