summaryrefslogtreecommitdiff
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
parent278f68e1e1398015a9de60ea2d6cf1ed0a1c87a5 (diff)
added option -a
-rw-r--r--CHANGELOG5
-rwxr-xr-xpwgrep.sh65
2 files changed, 46 insertions, 24 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 20e830f..86ea483 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,8 @@
+Mi 22. Dez 12:40:10 CET 2010 - v0.8-pre-4
+* Added option -a which searches all available databases at once.
+ This feature needs gpg-agent installed. Otherwise the gpg key passphrase
+ needs to be entered for each file separately .
+
Mi 22. Dez 11:49:33 CET 2010 - v0.8-pre-3
* Added WISHLIST file
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