Isolate the `grep -F' logic of list{,all}() in a filter() function - justdoit - Simpler (but with not all the features) reimplementation todo.txt CLI
(HTM) hg clone https://bitbucket.org/iamleot/justdoit
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
---
(DIR) changeset 648f03f0963213922a940d34a079708eb8424ddf
(DIR) parent 5e2635cf74274b7fadbbc115c0d5197d8f263bb1
(HTM) Author: Leonardo Taccari <iamleot@gmail.com>
Date: Sat, 18 Aug 2018 23:42:17
Isolate the `grep -F' logic of list{,all}() in a filter() function
Diffstat:
t.sh | 16 ++++++++++++++--
1 files changed, 14 insertions(+), 2 deletions(-)
---
diff -r 5e2635cf7427 -r 648f03f09632 t.sh
--- a/t.sh Sat Aug 18 14:21:59 2018 +0200
+++ b/t.sh Sat Aug 18 23:42:17 2018 +0200
@@ -123,7 +123,13 @@
file=$1
search=$2
- cat "${file}" | prettify | grep -F -- "${search}"
+ if [ "${search}" ]; then
+ filter() grep -F -- "${search}"
+ else
+ filter() cat
+ fi
+
+ cat "${file}" | prettify | filter
}
@@ -136,7 +142,13 @@
dfile=$2
search=$3
- cat "${dfile}" "${tfile}" | prettify | grep -F -- "${search}"
+ if [ "${search}" ]; then
+ filter() grep -F -- "${search}"
+ else
+ filter() cat
+ fi
+
+ cat "${dfile}" "${tfile}" | prettify | filter
}