From 7670e463c7fb7cf0f1e61c460afeeec8cb4480bd Mon Sep 17 00:00:00 2001 From: dmarakom6 Date: Wed, 30 Jun 2021 19:07:37 +0300 Subject: [PATCH] Fix -wsBug(72) --- util/notegrep/ws.sh | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/util/notegrep/ws.sh b/util/notegrep/ws.sh index c9166bf..67bc605 100644 --- a/util/notegrep/ws.sh +++ b/util/notegrep/ws.sh @@ -5,12 +5,28 @@ Released under the "All rights reserved" category. See the RIGHTS.txt file in /docs/github/ for its full text. info +grepv() {grep -v $regex $DEFAULT_PATH/$notename} #the command run when input is valid + +nomatch() { + echo -n "There are no matches.\nView note anyway?(Y/N): " && read view + case $view in + y | Y | yes | YES | Yes ) + cat $DEFAULT_PATH/$notename + return 0 + ;; + *) + echo "Cancelled." + return 0 + ;; + esac +} + if [ -f $DEFAULT_PATH/$notename ]; then if grep -vq $regex $DEFAULT_PATH/$notename ; then - grep -v $regex $DEFAULT_PATH/$notename - + test "$(cat $DEFAULT_PATH/$notename)" = "$(grep -v $regex $DEFAULT_PATH/$notename)" && nomatch || grepv && return 0 + else echo "Pattern matches the whole file." return 0