Skip to content

Commit b91b38f

Browse files
committed
Don't use "which" to make newer shellcheck happier
1 parent aa38b4a commit b91b38f

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

apply-format

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function error_exit() {
3030
########################
3131

3232
function show_help() {
33-
if [ -t 1 ] && which tput > /dev/null 2>&1; then
33+
if [ -t 1 ] && hash tput 2> /dev/null; then
3434
local -r b=$(tput bold)
3535
local -r i=$(tput sitm)
3636
local -r n=$(tput sgr0)
@@ -171,7 +171,7 @@ fi
171171
# clang-format.
172172
declare format="${CLANG_FORMAT:-}"
173173
if [ -z "$format" ]; then
174-
format=$(which clang-format)
174+
format=$(type -p clang-format)
175175
fi
176176

177177
if [ -z "$format" ]; then
@@ -206,8 +206,8 @@ if [ "$whole_file" = false ]; then
206206
done < <(compgen -G "/usr/local/clang+llvm*/share/clang/clang-format-diff.py" | sort "$sort_version" -r)
207207
# Maybe it's in the $PATH already? This is true for Ubuntu and Debian.
208208
paths_to_try+=( \
209-
"$(which clang-format-diff 2> /dev/null || echo "$invalid")" \
210-
"$(which clang-format-diff.py 2> /dev/null || echo "$invalid")" \
209+
"$(type -p clang-format-diff 2> /dev/null || echo "$invalid")" \
210+
"$(type -p clang-format-diff.py 2> /dev/null || echo "$invalid")" \
211211
)
212212
# Fedora.
213213
paths_to_try+=( \

git-pre-commit-format

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ set -o pipefail
1111

1212
readonly bash_source="${BASH_SOURCE[0]:-$0}"
1313

14-
if [ -t 1 ] && which tput > /dev/null 2>&1; then
14+
if [ -t 1 ] && hash tput 2> /dev/null; then
1515
readonly b=$(tput bold)
1616
readonly i=$(tput sitm)
1717
readonly n=$(tput sgr0)
@@ -272,7 +272,7 @@ if [ "$interactive" = false ]; then
272272
exit 1
273273
fi
274274

275-
if which colordiff > /dev/null 2>&1; then
275+
if hash colordiff 2> /dev/null; then
276276
colordiff < "$patch"
277277
else
278278
echo "${b}(Install colordiff to see this diff in color!)${n}"

0 commit comments

Comments
 (0)