[pass] Test tree version before passing argument only available in tree 1.7.0

Simon Séhier simon.sehier at camptocamp.com
Mon Dec 22 12:47:14 CET 2014


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi all,

This patch will ensure the command tree isn't called with arguments
only available from v1.7.0 when using older version.

Any feedback welcome.


- -- 
Simon Séhier

Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex

Tel : 00 33 4 79 44 44 94
Mail : simon.sehier at camptocamp.com
http://www.camptocamp.com/infrastructure/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iQIcBAEBAgAGBQJUmAS+AAoJEAVTR79RM6kYU3cP/2NjO4W0JMj87IJhtPI4OAuF
FdA+hd4IVMU4xcaNeipKAhGVNAmSYWu6HEfhNxQq5jar8ypR65WPukejoUGeahop
hnk2lsRqIFK5PdO1ojTwdRa/duoCyxvml+wAOepTOYQYjGIXTzTeNlb/5svMN/lo
WY+x1aUXrsn6SPFktLS5qzEwBxK6BjRAq1DU4N62oi1vbcxTwVnm7/T2sR8DmLXt
w/u/nn6Ap+qLJMuZjrbhmrSstu7SYD2wGIQWtjgM5eBfwA2iwnUyWcQOCuxeucUT
83C7evlvGuLJDijTAtVZeENEu9h9yexJiP3aOTRKoiXIwF+PdEYy3pLWDnpO8+i9
jca8J3/OmWv9/wGuFjjvG8xjzuxi61c+L3Hp5Qky+sW0+hi6Eo7lMz6a+beyYaoD
npfIfjYR2xeGMxASWSuyudqJQJfmOf7s4kCeZQRpwjyQ4sQuTer1AsU7+2tJ3NMO
BkRfrz0DDPsi1k3GxrMCYBiL3g46VI4fw7TqnIBj8LKUnHxNxHsYSKrR000o792s
quKcyIqRXgYhd/wOllNlraNqR2+KZgvFm0yanaCeiV13QwtSY9rUnwbchDamrwZY
uwOqGG6aFrF5njoNyUFuxSPXCdoAbH0PciVS2gRHqdMWvKB5RppxghwNoZ/K2jbA
UTOE2Dm3P3TzJghq1nbC
=PQkC
-----END PGP SIGNATURE-----
-------------- next part --------------
From a744cc70dc390ac06749fc8fb9a6e8baaab73096 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Simon=20S=C3=A9hier?= <simon.sehier at camptocamp.com>
Date: Mon, 22 Dec 2014 10:43:47 +0100
Subject: [PATCH] Check tree version for options

 - matchdirs and ignore-case options are available from version v1.7.0
---
 src/password-store.sh | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/src/password-store.sh b/src/password-store.sh
index c85cc33..1c645c3 100755
--- a/src/password-store.sh
+++ b/src/password-store.sh
@@ -6,6 +6,11 @@
 umask "${PASSWORD_STORE_UMASK:-077}"
 set -o pipefail
 
+TREE=$(which tree)
+if [ -n "$TREE" ];then
+  TREE_VER=$(tree --version | awk '{print $2}')
+fi
+
 GPG_OPTS=( "--quiet" "--yes" "--compress-algo=none" )
 GPG="gpg"
 which gpg2 &>/dev/null && GPG="gpg2"
@@ -344,7 +349,15 @@ cmd_find() {
 	[[ -z "$@" ]] && die "Usage: $PROGRAM $COMMAND pass-names..."
 	IFS="," eval 'echo "Search Terms: $*"'
 	local terms="*$(printf '%s*|*' "$@")"
-	tree -C -l --noreport -P "${terms%|*}" --prune --matchdirs --ignore-case "$PREFIX" | tail -n +2 | sed 's/\.gpg$//'
+	case "$TREE_VER" in
+		v1.[0-6]*)
+			TREE_OPTS=""
+			;;
+		*)
+			TREE_OPTS="--matchdirs --ignore-case"
+			;;
+	esac
+	tree -C -l --noreport -P "${terms%|*}" --prune ${TREE_OPTS} "$PREFIX" | tail -n +2 | sed 's/\.gpg$//'
 }
 
 cmd_grep() {
-- 
2.2.0

-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.a744cc70dc390ac06749fc8fb9a6e8baaab73096.sig
Type: application/pgp-signature
Size: 543 bytes
Desc: not available
URL: <http://lists.zx2c4.com/pipermail/password-store/attachments/20141222/7b192645/attachment.sig>


More information about the Password-Store mailing list