aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authortypebrook <typebrook@gmail.com>2020-03-30 13:07:00 +0800
committertypebrook <typebrook@gmail.com>2020-03-30 13:07:00 +0800
commit33e44f1fff14c0ea52adaaaee909de5cf21615b3 (patch)
treedbc0592eb9815bffd26a2595f0097f23c51598db
parent716c274f53e42205da05d0957b5788afc48ff228 (diff)
Fix runtime error
Only output the first line of grep result in files
-rwxr-xr-xgist2
1 files changed, 1 insertions, 1 deletions
diff --git a/gist b/gist
index d61f86b..5c393d5 100755
--- a/gist
+++ b/gist
@@ -343,7 +343,7 @@ _grep_content() {
343 # grep from filenames 343 # grep from filenames
344 local file=$(ls $repo | grep --color=always -Ei "$1") 344 local file=$(ls $repo | grep --color=always -Ei "$1")
345 # grep from content of files 345 # grep from content of files
346 local content=$(grep --color=always -EHi -m1 "$1" *) 346 local content=$(grep --color=always -EHi -m1 "$1" * | head -1)
347 347
348 [[ -n $file && file="$file\n" || -n $content ]] \ 348 [[ -n $file && file="$file\n" || -n $content ]] \
349 && hint=false mark="$index " _show_list \ 349 && hint=false mark="$index " _show_list \