summaryrefslogtreecommitdiff
path: root/pwgrep.sh
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2010-12-22 11:41:56 +0000
committerPaul Buetow <paul@buetow.org>2010-12-22 11:41:56 +0000
commita2128832279dc74b919afcd9080f30b413f73e45 (patch)
tree5ccdc9b6cfb6af4329ed3d27db38fa7de4f2a9ee /pwgrep.sh
parent278f68e1e1398015a9de60ea2d6cf1ed0a1c87a5 (diff)
added option -a
Diffstat (limited to 'pwgrep.sh')
-rwxr-xr-xpwgrep.sh65
1 files changed, 41 insertions, 24 deletions
diff --git a/pwgrep.sh b/pwgrep.sh
index 6908cf6..8df11fd 100755
--- a/pwgrep.sh
+++ b/pwgrep.sh
@@ -1,6 +1,6 @@
#!/bin/bash
-# pwgrep v0.8-pre-3 (c) 2009, 2010 by Paul Buetow
+# pwgrep v0.8-pre-4 (c) 2009, 2010 by Paul Buetow
# pwgrep helps you to manage all your passwords using GnuGP
# for encryption and a versioning system (subversion by default)
# for keeping track all changes of your password database. In
@@ -127,25 +127,33 @@ function setwipecmd () {
function pwgrep () {
search=$1
- info Searching for $search
-
- gpg --decrypt $PWGREPDB | $AWK -v search="$search" '
- BEGIN {
- flag=0
- IGNORECASE=1
- }
- !/^\t/ {
- if (!flag && $0 ~ search) {
- flag=1
- print $0
- } else if (flag && $0 ~ search) {
- print $0
- } else if (flag) {
- flag=0
- }
- } /^\t/ && flag {
- print $0
- }'
+
+ if [ -z "$ALL" ]; then
+ dbs=$PWGREPDB
+ else
+ dbs=$(_pwdbls | sed 's/$/.gpg/')
+ fi
+
+ for db in $dbs; do
+ info Searching for $search in $db
+ gpg --use-agent --decrypt $db | $AWK -v search="$search" '
+ BEGIN {
+ flag=0
+ IGNORECASE=1
+ }
+ !/^\t/ {
+ if (!flag && $0 ~ search) {
+ flag=1
+ print $0
+ } else if (flag && $0 ~ search) {
+ print $0
+ } else if (flag) {
+ flag=0
+ }
+ } /^\t/ && flag {
+ print $0
+ }'
+ done
}
function pwupdate () {
@@ -167,9 +175,13 @@ function pwedit () {
[ -z "$NOVERSIONING" ] && $VERSIONCOMMIT
}
+function _pwdbls () {
+ ls *.gpg | sed 's/\.gpg$//'
+}
+
function pwdbls () {
echo Available Databases:
- ls *.gpg | sed 's/\.gpg$//'
+ _pwdbls
echo Current database: $PWGREPDB
}
@@ -286,9 +298,14 @@ function set_opts () {
;;
-a*)
# All DBs at once
- ALL=1
- ARGS=${ARGS[@]:2}
- set_opts
+ which gpg-agent
+ if [ $? == "0" ]; then
+ ALL=1
+ ARGS=${ARGS[@]:2}
+ set_opts
+ else
+ error You need gpg-agent installed
+ fi
;;
*)
esac