aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2013-11-25 22:04:56 -0200
committerSilvio Rhatto <rhatto@riseup.net>2013-11-25 22:04:56 -0200
commit41963ff0f4eccca14dd7a656a2ac8eb7beb2fd85 (patch)
treebf15cc9b62915c1f2e239b6aae1e377152978b71 /lib
parent7d5aea9198395255062c71f2695044a8f98fc891 (diff)
downloadkeyringer-41963ff0f4eccca14dd7a656a2ac8eb7beb2fd85.tar.gz
keyringer-41963ff0f4eccca14dd7a656a2ac8eb7beb2fd85.tar.bz2
Avoid bash arrays on append action (closes #26)
Diffstat (limited to 'lib')
-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