@@ -294,7 +294,7 @@ validate_environment() {
294
294
# Check if the necessary history file exists and is readable and writable
295
295
if (( GHFC_HISTORY_LIMIT)) ; then
296
296
if [[ -d $GHFC_HISTORY_FILE ]]; then
297
- die " $GHFC_HISTORY_FILE is a directory"
297
+ die " ' $GHFC_HISTORY_FILE ' is a directory. Please specify a file path for the GHFC_HISTORY_FILE. "
298
298
fi
299
299
300
300
if [[ ! -f $GHFC_HISTORY_FILE ]]; then
@@ -683,7 +683,9 @@ gh_query() {
683
683
grep_args+=(" --regexp=$pattern " )
684
684
done
685
685
686
- # Run the grep command directly with the expanded array
686
+ # Use the '--text' flag, as grep will simply print 'Binary file … matches' if
687
+ # the file contains binary characters. It won't even throw an error.
688
+ # https://unix.stackexchange.com/questions/19907
687
689
command grep --color=never --line-number --text --fixed-strings " ${grep_args[@]} " -- \
688
690
" ${store_file_contents} _${index} _fetched" 2> " ${redirect_location} " |
689
691
command cut -d: -f1 >> " ${store_file_contents} _${index} _line_numbers"
@@ -782,13 +784,15 @@ view_contents() {
782
784
bat_args+=(" --language=${file_extension} " )
783
785
fi
784
786
line_numbers=()
785
- while IFS= read -r matched_line; do
786
- line_numbers+=(" $matched_line " )
787
- # NOTE: The '--line-range' in 'bat' overrides preceding flags. However, the
788
- # '-H, --highlight-line' attribute can be utilized multiple times.
789
- # https://github.com/sharkdp/bat/pull/162#pullrequestreview-125072252
790
- # use the short form to avoid making the command unnecessarily long
791
- bat_args+=(" -H=${matched_line} " )
787
+ while IFS=$' \n ' read -r matched_line; do
788
+ if [[ $matched_line =~ ^[0-9]+ ]]; then
789
+ line_numbers+=(" $matched_line " )
790
+ # NOTE: The '--line-range' in 'bat' overrides preceding flags. However, the
791
+ # '-H, --highlight-line' attribute can be utilized multiple times.
792
+ # https://github.com/sharkdp/bat/pull/162#pullrequestreview-125072252
793
+ # use the short form to avoid making the command unnecessarily long
794
+ bat_args+=(" -H=${matched_line} " )
795
+ fi
792
796
done < " ${store_file_contents} _${index} _line_numbers"
793
797
794
798
file_name=$( command basename " $file_path " )
0 commit comments