password-store

Simple password manager using gpg and ordinary unix directories
git clone https://git.zx2c4.com/password-store
Log | Files | Refs | README | LICENSE

commit 9d92e5bca1543be40270c288feb546df0382afee
parent bdc3bacff7e149933275fa4ecbc5644773ca12c5
Author: Jason A. Donenfeld <Jason@zx2c4.com>
Date:   Thu, 24 Apr 2014 11:32:32 +0200

Don't prompt for questions when stdin is not a tty.

Diffstat:
Msrc/password-store.sh | 5+++--
Mtests/setup.sh | 6++----
Mtests/t0060-rm-tests.sh | 2+-
3 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/src/password-store.sh b/src/password-store.sh @@ -35,6 +35,7 @@ git_commit() { git commit $sign -m "$1" } yesno() { + [[ -t 0 ]] || return 0 local response read -r -p "$1 [y/N] " response [[ $response == [yY] ]] || exit 1 @@ -75,7 +76,7 @@ set_gpg_recipients() { done < "$current" } agent_check() { - [[ -n $GPG_AGENT_INFO ]] || yesno "$(cat <<-_EOF + [[ ! -t 0 || -n $GPG_AGENT_INFO ]] || yesno "$(cat <<-_EOF You are not running gpg-agent. This means that you will need to enter your password for each and every gpg file that pass processes. This could be quite tedious. @@ -559,7 +560,7 @@ cmd_copy_move() { [[ -d $old_path || -d $new_path || $new_path =~ /$ ]] || new_path="${new_path}.gpg" local interactive="-i" - [[ $force -eq 1 ]] && interactive="-f" + [[ ! -t 0 || $force -eq 1 ]] && interactive="-f" if [[ $move -eq 1 ]]; then mv $interactive -v "$old_path" "$new_path" || exit 1 diff --git a/tests/setup.sh b/tests/setup.sh @@ -38,10 +38,8 @@ chmod 700 "$GNUPGHOME" GPG="gpg" which gpg2 &>/dev/null && GPG="gpg2" -# We don't want to use any running agent. -# We want an agent to appear to pass to be running. -# We don't need a real agent. Hence: -[[ $GPG == "gpg2" ]] && export GPG_AGENT_INFO=" " || unset GPG_AGENT_INFO +# We don't want any currently running agent to conflict. +unset GPG_AGENT_INFO KEY1="CF90C77B" # pass test key 1 KEY2="D774A374" # pass test key 2 diff --git a/tests/t0060-rm-tests.sh b/tests/t0060-rm-tests.sh @@ -7,7 +7,7 @@ cd "$(dirname "$0")" test_expect_success 'Test "rm" command' ' "$PASS" init $KEY1 && "$PASS" generate cred1 43 && - echo "y" | "$PASS" rm cred1 && + "$PASS" rm cred1 && [[ ! -e $PASSWORD_STORE_DIR/cred1.gpg ]] '