summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2012-09-13 08:14:35 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2012-09-13 08:14:43 +0200
commit709808d22cf09390b5404b7bfc42f3243d9577d4 (patch)
tree447b8d16518a4e9574d674240da5fa946822bd39
parent69b811e0f34a2f57329e5cdfebcd16c210f24458 (diff)
downloadpass-709808d22cf09390b5404b7bfc42f3243d9577d4.tar.gz
pass-709808d22cf09390b5404b7bfc42f3243d9577d4.tar.bz2
pass-709808d22cf09390b5404b7bfc42f3243d9577d4.zip
Split out common gpg options into variable.
Reported-by: Brian Mattern <rephorm@rephorm.com>
-rwxr-xr-xsrc/password-store.sh13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/password-store.sh b/src/password-store.sh
index db6f4ee..2488385 100755
--- a/src/password-store.sh
+++ b/src/password-store.sh
@@ -8,6 +8,7 @@ umask 077
PREFIX="${PASSWORD_STORE_DIR:-$HOME/.password-store}"
ID="$PREFIX/.gpg-id"
GIT="$PREFIX/.git"
+GPG_OPTS="--quiet --yes --batch"
export GIT_DIR="$GIT"
export GIT_WORK_TREE="$PREFIX"
@@ -197,7 +198,7 @@ case "$command" in
if [[ $ml -eq 1 ]]; then
echo "Enter contents of $path and press Ctrl+D when finished:"
echo
- cat | gpg -e -r "$ID" -o "$passfile" --yes
+ cat | gpg -e -r "$ID" -o "$passfile" $GPG_OPTS
elif [[ $noecho -eq 1 ]]; then
while true; do
read -p "Enter password for $path: " -s password
@@ -205,7 +206,7 @@ case "$command" in
read -p "Retype password for $path: " -s password_again
echo
if [[ $password == $password_again ]]; then
- gpg -q -e -r "$ID" -o "$passfile" --yes <<<"$password"
+ gpg -e -r "$ID" -o "$passfile" $GPG_OPTS <<<"$password"
break
else
echo "Error: the entered passwords do not match."
@@ -213,7 +214,7 @@ case "$command" in
done
else
read -p "Enter password for $path: " -e password
- gpg -q -e -r "$ID" -o "$passfile" --yes <<<"$password"
+ gpg -e -r "$ID" -o "$passfile" $GPG_OPTS <<<"$password"
fi
if [[ -d $GIT ]]; then
git add "$passfile"
@@ -248,11 +249,11 @@ case "$command" in
action="Added"
if [[ -f $passfile ]]; then
- gpg -q -d -o "$tmp_file" --yes --batch "$passfile" || exit 1
+ gpg -d -o "$tmp_file" $GPG_OPTS "$passfile" || exit 1
action="Edited"
fi
${EDITOR:-vi} "$tmp_file"
- while ! gpg -q -e -r "$ID" -o "$passfile" --yes "$tmp_file"; do
+ while ! gpg -e -r "$ID" -o "$passfile" $GPG_OPTS "$tmp_file"; do
echo "GPG encryption failed. Retrying."
sleep 1
done
@@ -288,7 +289,7 @@ case "$command" in
mkdir -p -v "$PREFIX/$(dirname "$path")"
pass="$(pwgen -s $symbols $length 1)"
passfile="$PREFIX/$path.gpg"
- gpg -q -e -r "$ID" -o "$passfile" --yes <<<"$pass"
+ gpg -e -r "$ID" -o "$passfile" $GPG_OPTS <<<"$pass"
if [[ -d $GIT ]]; then
git add "$passfile"
git commit -m "Added generated password for $path to store."