Skip to content

Commit

Permalink
fix: ensure '--color=always' flag with 'bat' to fix exit status
Browse files Browse the repository at this point in the history
  • Loading branch information
LangLangBart committed Jun 26, 2024
1 parent 727750b commit 44257df
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion gh-find-code
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,10 @@ view_contents() {
"--color=always"
)

[[ $file_extension != "null" ]] && if command "$bat_executable" --language "$file_extension" <<<"test" >/dev/null 2>&1; then
# NOTE: The '--color=always' flag is important as it alters the exit status when all output is
# redirected to /dev/null. This is a very unintuitive design decision by 'bat' or a bug.
[[ $file_extension != "null" ]] && if command "$bat_executable" --color=always \
--language "$file_extension" <<<"test" &>/dev/null; then
bat_args+=("--language=${file_extension}")
fi
IFS=' ' read -ra line_numbers <"${store_file_contents}_${index}_line_numbers"
Expand Down

0 comments on commit 44257df

Please sign in to comment.