Fix output bug
Fix -cf and -sf returning "No such file" or proceeding in normal grep mode
This commit is contained in:
parent
25092fe9b4
commit
e3f7e7414f
3 changed files with 22 additions and 18 deletions
|
@ -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
|
||||
|
@ -168,24 +170,26 @@ function notegrep() {
|
|||
export regex=$2
|
||||
export option=$1
|
||||
. ~/.shellnotes/util/notegrep/sf.sh
|
||||
;;
|
||||
*)
|
||||
if [ -z $notename ]; then
|
||||
echo "Invalid input."
|
||||
cd $DIR
|
||||
return 0
|
||||
|
||||
elif [ -z $regex ]; then
|
||||
echo "No pattern given."
|
||||
cd $DIR
|
||||
return 0
|
||||
fi
|
||||
|
||||
do_grep
|
||||
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
if [ -z $notename ]; then
|
||||
echo "Invalid input."
|
||||
cd $DIR
|
||||
return 0
|
||||
|
||||
elif [ -z $regex ]; then
|
||||
echo "No pattern given."
|
||||
cd $DIR
|
||||
return 0
|
||||
fi
|
||||
|
||||
|
||||
do_grep
|
||||
|
||||
|
||||
fi
|
||||
|
||||
unset GREP_OPTIONS
|
||||
|
|
|
@ -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/*
|
||||
|
|
|
@ -11,4 +11,4 @@ if [ $files -ge 1 ]; then
|
|||
grep -rwl $regex $DEFAULT_PATH/*
|
||||
else
|
||||
echo "No matching files found."
|
||||
fi
|
||||
fi
|
||||
|
|
Loading…
Reference in a new issue