mirror of
https://github.com/octoleo/Purse.git
synced 2024-12-29 12:32:39 +00:00
Include timestamp in safe. Fix #28.
This commit is contained in:
parent
072dac54e9
commit
744f9b2a68
7
pwd.sh
7
pwd.sh
@ -6,7 +6,7 @@ set -o errtrace
|
|||||||
set -o nounset
|
set -o nounset
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
|
|
||||||
filter="$(command -v grep) -v --regexp"
|
filter="$(command -v grep) -v -E"
|
||||||
gpg="$(command -v gpg || command -v gpg2)"
|
gpg="$(command -v gpg || command -v gpg2)"
|
||||||
safe="${PWDSH_SAFE:=pwd.sh.safe}"
|
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 safe exists, decrypt it and filter out username, or bail on error.
|
||||||
# If successful, append entry, or blank line.
|
# 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.
|
# Finally, encrypt it all to a new safe file, or fail.
|
||||||
# If successful, update to new safe file.
|
# If successful, update to new safe file.
|
||||||
( if [[ -f "${safe}" ]] ; then
|
( if [[ -f "${safe}" ]] ; then
|
||||||
@ -136,7 +136,7 @@ write_pass () {
|
|||||||
${filter} " ${username}$" || return
|
${filter} " ${username}$" || return
|
||||||
fi ; \
|
fi ; \
|
||||||
echo "${entry}") | \
|
echo "${entry}") | \
|
||||||
${filter} "^[[:space:]]*$" | \
|
(${filter} "^[[:space:]]*$|^mtime:[[:digit:]]+$";echo mtime:$(date +%s)) | \
|
||||||
encrypt ${password} ${safe}.new - || fail "Write to safe failed"
|
encrypt ${password} ${safe}.new - || fail "Write to safe failed"
|
||||||
mv ${safe}.new ${safe}
|
mv ${safe}.new ${safe}
|
||||||
}
|
}
|
||||||
@ -211,4 +211,3 @@ fi
|
|||||||
|
|
||||||
tput setaf 2 2 2 ; echo "
|
tput setaf 2 2 2 ; echo "
|
||||||
Done" ; tput sgr0
|
Done" ; tput sgr0
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user