summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xlib/keyringer/actions/append28
1 files changed, 5 insertions, 23 deletions
diff --git a/lib/keyringer/actions/append b/lib/keyringer/actions/append
index e945bff..e307056 100755
--- a/lib/keyringer/actions/append
+++ b/lib/keyringer/actions/append
@@ -10,29 +10,11 @@ source "$LIB" || exit 1
# Get file
keyringer_get_file "$2"
-OLDIFS="$IFS"
-IFS=$'\n'
-
-CONTENT=($(keyringer_exec decrypt "$BASEDIR" "$FILE"))
-
+# Only display directions if we're running append, not append-batch
if [ "$BASENAME" == "append" ]; then
- # only display directions if we're running append, not append-batch
- printf "\n%s currently has %d lines\n\n" "$FILE" "${#CONTENT[@]}"
- printf "Now please write the content to be appended on %s, finnishing with Ctrl-D:\n" "$FILE"
-fi
-
-APPEND=($(cat -))
-
-NEW=( ${CONTENT[@]} ${APPEND[@]} )
-
-for element in $(seq 0 $((${#NEW[@]} - 1))); do
- echo ${NEW[$element]}
-done | keyringer_exec encrypt-batch $BASEDIR $FILE
-
-err="$?"
-
-if [ "$err" != "0" ]; then
- exit "$err"
+ printf "Please write the content to be appended on %s, finnishing with Ctrl-D:\n" "$FILE"
fi
-IFS="$OLDIFS"
+# Append content to an existing secret
+( keyringer_exec decrypt "$BASEDIR" "$FILE" && cat ) | \
+ keyringer_exec encrypt-batch $BASEDIR $FILE