aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEinhard Leichtfuß <alguien@respiranto.de>2018-12-24 03:39:08 +0100
committerEinhard Leichtfuß <alguien@respiranto.de>2018-12-24 03:39:08 +0100
commitdaa05919b8aaaa4f08c851e7ff7c76b42d74ed31 (patch)
tree180ee43bf2a0eccb9cbeb6f6ff8505207681a7fe
parent45c9d281031760ef0548c69084cbc411d1376ac8 (diff)
Switch to EREs for --search-by-data
Also, use `rm -f' for deletion instead of plain `rm'.
-rw-r--r--CHANGELOG1
-rw-r--r--ctct.in12
2 files changed, 7 insertions, 6 deletions
diff --git a/CHANGELOG b/CHANGELOG
index bb41ddf..c0a2c5c 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -13,6 +13,7 @@ General:
- Keep temporary files private and delete them once no longer needed.
`- This might have particularly have been an issue, if a de-/encrypting
{input,ouput}_program was used.
+- Switch to extended regular expressions (EREs) for `--search-by-data'.
Compatibility:
diff --git a/ctct.in b/ctct.in
index 624566c..c40c15e 100644
--- a/ctct.in
+++ b/ctct.in
@@ -2,7 +2,7 @@
#
# ctct - a simple console contact manager
#
-# Copyright 2015 - 2017 Einhard Leichtfuß
+# Copyright 2015 - 2018 Einhard Leichtfuß
#
# ctct is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
@@ -59,7 +59,7 @@ EOF
function cleanup()
{
- test -v tmp_file && test -f "$tmp_file" && rm "$tmp_file"
+ test -v tmp_file && test -f "$tmp_file" && rm -f "$tmp_file"
}
trap cleanup EXIT
@@ -186,7 +186,7 @@ function search_file()
for file in "$datadir"/*
do
- # NEW
+ # Ignore non-regular files.
test -f "$file" || continue
valid=true
@@ -194,13 +194,13 @@ function search_file()
then
for pattern in "$@"
do
- ! grep -qi "$pattern" "$file" && valid=false && break
+ ! grep -qEi "$pattern" "$file" && valid=false && break
done
else
for pattern in "$@"
do
! eval "$output_program" < "$file" | \
- grep -qi "$pattern" "$file" && valid=false && break
+ grep -qEi "$pattern" "$file" && valid=false && break
done
fi
if $valid
@@ -255,7 +255,7 @@ function edit_file()
! $new && eval "$output_program" < "$file" > "$tmp_file"
"$editor" "$tmp_file"
eval "$input_program" < "$tmp_file" > "$file"
- rm "$tmp_file" && unset tmp_file
+ rm -f "$tmp_file" && unset tmp_file
fi
}