Include timestamp in safe. Fix #28.

This commit is contained in:
drduh 2016-07-20 16:19:14 +10:00 committed by GitHub
parent 072dac54e9
commit 744f9b2a68
1 changed files with 3 additions and 4 deletions

7
pwd.sh
View File

@ -6,7 +6,7 @@ set -o errtrace
set -o nounset
set -o pipefail
filter="$(command -v grep) -v --regexp"
filter="$(command -v grep) -v -E"
gpg="$(command -v gpg || command -v gpg2)"
safe="${PWDSH_SAFE:=pwd.sh.safe}"
@ -128,7 +128,7 @@ write_pass () {
# If safe exists, decrypt it and filter out username, or bail on error.
# If successful, append entry, or blank line.
# Filter out any blank lines.
# Filter blank lines and previous timestamp, append fresh timestamp.
# Finally, encrypt it all to a new safe file, or fail.
# If successful, update to new safe file.
( if [[ -f "${safe}" ]] ; then
@ -136,7 +136,7 @@ write_pass () {
${filter} " ${username}$" || return
fi ; \
echo "${entry}") | \
${filter} "^[[:space:]]*$" | \
(${filter} "^[[:space:]]*$|^mtime:[[:digit:]]+$";echo mtime:$(date +%s)) | \
encrypt ${password} ${safe}.new - || fail "Write to safe failed"
mv ${safe}.new ${safe}
}
@ -211,4 +211,3 @@ fi
tput setaf 2 2 2 ; echo "
Done" ; tput sgr0