Fix output bug

Fix -cf and -sf returning "No such file" or proceeding in normal grep mode
This commit is contained in:
dmarakom6 2021-06-28 13:42:57 +03:00
parent 25092fe9b4
commit e3f7e7414f
3 changed files with 22 additions and 18 deletions

View file

@ -130,8 +130,9 @@ function notegrep() {
-cl | --count-lines )
. ~/.shellnotes/util/notegrep/cl.sh
;;
-sl | --show-lines )
. ~/.shellnotes/util/notegrep/sl.sh
;;
*)
echo "Invalid parameter. Proceeding in normal grep mode."
do_grep
@ -145,6 +146,7 @@ function notegrep() {
if [ $# -eq 0 ]; then
echo -n "Enter regex: " && read regex
echo -n "Enter note name: " && read notename
do_grep
else
if [ $# -eq 3 ]; then
export option=$1
@ -169,9 +171,7 @@ function notegrep() {
export option=$1
. ~/.shellnotes/util/notegrep/sf.sh
;;
esac
*)
if [ -z $notename ]; then
echo "Invalid input."
cd $DIR
@ -183,9 +183,13 @@ function notegrep() {
return 0
fi
do_grep
;;
esac
fi
unset GREP_OPTIONS

View file

@ -11,7 +11,7 @@ if [ $files -eq 1 ]; then
echo "Found $files matching file in $DEFAULT_PATH."
elif [ $files -gt 1 ]; then
echo "Found $files matching files in $DEFAULT_PATH."
echo -n "Show files? " && read show
echo -n "Show files?(Y/N): " && read show
case $show in
yes | y | Y | YES | Yes )
grep -rwl $regex $DEFAULT_PATH/*