pss

git clone https://orangeshoelaces.net/git/pss.git

4a9984cdb470227c1966ff27662877dde7eb7550

Author: Vasilii Kolobkov on 12/09/2018

Committer: Vasilii Kolobkov on 12/09/2018

Add records nonchalantly when the stash didn't exist

Stats

pss | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

Patch

diff --git a/pss b/pss
index dd70e8f..b6fdc3d 100755
--- a/pss
+++ b/pss
@@ -58,7 +58,7 @@ add_rec() {
 		secrets_new="${secrets}.new"
 		secrets_old="${secrets}.old"
 		{
-			gpg --decrypt "${secrets}"
+			[ -f "${secrets}" ] && gpg --decrypt "${secrets}"
 			{
 				echo "${name}"
 				echo "${password}"
@@ -66,9 +66,9 @@ add_rec() {
 				echo "${notes}"
 			} | pr -4 -t -s"${field_separator}"
 		} | gpg --encrypt --default-recipient-self > "${secrets_new}"
-		mv "${secrets}" "${secrets_old}"
+		[ -f "${secrets}" ] && mv "${secrets}" "${secrets_old}"
 		mv "${secrets_new}" "${secrets}"
-		unlink "${secrets_old}"
+		[ -f "${secrets_old}" ] && unlink "${secrets_old}"
 	)
 }