Use type instead of which in shell scripts

The latter is not a Bash built-in,
and some environments turn out to produce non-conforming
return codes.

`type` is provided by Bash itself,
so we can rely on it better.
This commit is contained in:
ISSOtm
2026-05-05 16:03:33 +02:00
parent f0161b41c8
commit fa22b78e7d
2 changed files with 3 additions and 3 deletions
+2 -2
View File
@@ -188,7 +188,7 @@ evaluateDepTest () {
"$RGBASM" $RGBASMFLAGS -o "$o" "$i"/a.asm >"$output" 2>"$errput" "$RGBASM" $RGBASMFLAGS -o "$o" "$i"/a.asm >"$output" 2>"$errput"
fixed_output="$input" fixed_output="$input"
if which cygpath &>/dev/null; then if type -t cygpath >/dev/null; then
# MinGW needs the Windows path substituted but with forward slash separators; # MinGW needs the Windows path substituted but with forward slash separators;
# Cygwin has `cygpath` but just needs the original path substituted. # Cygwin has `cygpath` but just needs the original path substituted.
subst1="$(printf '%s\n' "$o" | sed 's:[][\/.^$*]:\\&:g')" subst1="$(printf '%s\n' "$o" | sed 's:[][\/.^$*]:\\&:g')"
@@ -215,7 +215,7 @@ evaluateDepTest "continues-after-missing-preinclude"
evaluateDepTest "exits-after-missing-preinclude" evaluateDepTest "exits-after-missing-preinclude"
i="state-file" i="state-file"
if which cygpath &>/dev/null; then if type -t cygpath >/dev/null; then
# MinGW translates path names before passing them as command-line arguments, # MinGW translates path names before passing them as command-line arguments,
# but does not do so when they are prefixed, so we have to do it ourselves. # but does not do so when they are prefixed, so we have to do it ourselves.
state_outname="$(cygpath -w "$o")" state_outname="$(cygpath -w "$o")"
+1 -1
View File
@@ -10,7 +10,7 @@ trap "cd; rm -rf ${tmpdir@Q}" EXIT
src="$PWD" src="$PWD"
cd "$tmpdir" || exit cd "$tmpdir" || exit
if which cygpath &>/dev/null; then if type -t cygpath >/dev/null; then
# MinGW needs the Windows path substituted but with forward slash separators; # MinGW needs the Windows path substituted but with forward slash separators;
# Cygwin has `cygpath` but just needs the original path substituted. # Cygwin has `cygpath` but just needs the original path substituted.
subst1="$(printf '%s\n' "$src" | sed 's:[][\/.^$*]:\\&:g')" subst1="$(printf '%s\n' "$src" | sed 's:[][\/.^$*]:\\&:g')"