diff options
author | typebrook <typebrook@gmail.com> | 2020-05-13 17:30:27 +0800 |
---|---|---|
committer | typebrook <typebrook@gmail.com> | 2020-05-13 17:30:27 +0800 |
commit | d88a5e550f89aa49604473cf8820c434f9da3e17 (patch) | |
tree | afedc1550dcc76feb88286600fef7101239a34b7 | |
parent | 82b76db82cd86693008817806a2c5a160b15b889 (diff) |
Suppress error msg with insane filename
-rwxr-xr-x | gist | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -385,7 +385,8 @@ _grep_content() { | |||
385 | # grep from filenames | 385 | # grep from filenames |
386 | local file=$(ls $repo | grep --color=always -Ei "$1") | 386 | local file=$(ls $repo | grep --color=always -Ei "$1") |
387 | # grep from content of files | 387 | # grep from content of files |
388 | local content=$(grep --color=always -EHi -m1 "$1" * | head -1) | 388 | # Abort error message to prevent weird file name, for example: https://gist.github.com/6057f4a3a533f7992c60 |
389 | local content=$(grep --color=always -EHi -m1 "$1" * 2>/dev/null | head -1) | ||
389 | 390 | ||
390 | [[ -n $file && file="$file\n" || -n $content ]] \ | 391 | [[ -n $file && file="$file\n" || -n $content ]] \ |
391 | && hint=false mark="$index " _show_list \ | 392 | && hint=false mark="$index " _show_list \ |