From daa05919b8aaaa4f08c851e7ff7c76b42d74ed31 Mon Sep 17 00:00:00 2001 From: Einhard Leichtfuß Date: Mon, 24 Dec 2018 03:39:08 +0100 Subject: Switch to EREs for --search-by-data Also, use `rm -f' for deletion instead of plain `rm'. --- CHANGELOG | 1 + ctct.in | 12 ++++++------ 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 } -- cgit v1.2.3