summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--passwort-tresor.in18
1 files changed, 13 insertions, 5 deletions
diff --git a/passwort-tresor.in b/passwort-tresor.in
index fd7c6ae..4611f83 100644
--- a/passwort-tresor.in
+++ b/passwort-tresor.in
@@ -197,13 +197,21 @@ beiFehlerBeenden 1
if ${greppw}
then
- for suchStr in "${suche}" "${suche}.*:\$" "^${suche}.*:\$" "^${suche}:\$" ""
- do
- [ $(grep -c "${suchStr}" "${tmpDir}/output") -eq 1 ] && break
+ count=0
+ for subst in 's/[.[]/\\\0/g' ''; do
+ sucheSubst=$(
+ echo "${suche}" | \
+ sed "${subst}"
+ )
+ for suchStr in "${sucheSubst}" "${sucheSubst}.*:\$" "^${sucheSubst}.*:\$" "^${sucheSubst}:\$"
+ do
+ count=$(grep -c "${suchStr}" "${tmpDir}/output")
+ [ "${count}" -eq 1 ] && break
+ done
done
- if [ -z "${suchStr}" ]
+ if [ "${count}" -ne 1 ]
then
- >&2 echo "'${suche}' ist nicht genau ein Mal vorhanden!"
+ >&2 printf '"%s" ist nicht genau ein Mal vorhanden!\n' "${suche}"
beenden 1
fi
output="$(grep -2 "${suchStr}" "${tmpDir}/output" | tail -n2)"