Junio C Hamano <gitster@xxxxxxxxx> writes: > This may be in the "POSIX may say this but the real world may not > work that way" territory. As far as I can tell, "command -v" [*1*] > and "type" [*2*] both ought to give diagnostic messages to their > standard error stream, and they both should signal an error with > non-zero exit status. It may be that the shell implementation you > have tried had "command -v" that is less noisy than "type" when > given a command that is not installed, but I wonder if the next > shell implementation you find has "command -v" that is as noisy and > scary as "type", in which case this patch amounts to a no-op. > > I wonder if "type p4d >/dev/null 2>/dev/null" (or "command -v" with > the same) is a more futureproof fix. So, how about replacing it with something like this? ----- >8 --------- >8 --------- >8 --------- >8 --------- >8 ----- From: Carlo Marcelo Arenas Belón <carenas@xxxxxxxxx> In preparation for a future change that will make perforce installation optional in macOS, make sure that the check for it is done without triggering scary looking errors and add a user friendly message instead. All other existing uses of 'type <cmd>' in our shell scripts that check the availability of a command <cmd> send both standard output and error stream to /dev/null to squelch "<cmd> not found" diagnostic output, but this script left the standard error stream shown. Redirect it just like everybody else to squelch this error message that we fully expect to see. Helped-by: Eric Sunshine <sunshine@xxxxxxxxxxxxxx> Signed-off-by: Carlo Marcelo Arenas Belón <carenas@xxxxxxxxx> Signed-off-by: Junio C Hamano <gitster@xxxxxxxxx> --- ci/install-dependencies.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ci/install-dependencies.sh b/ci/install-dependencies.sh index dbcebad2fb..e598dc28df 100755 --- a/ci/install-dependencies.sh +++ b/ci/install-dependencies.sh @@ -78,14 +78,16 @@ linux-gcc-default) ;; esac -if type p4d >/dev/null && type p4 >/dev/null +if type p4d >/dev/null 2>&1 && type p4 >/dev/null 2>&1 then echo "$(tput setaf 6)Perforce Server Version$(tput sgr0)" p4d -V | grep Rev. echo "$(tput setaf 6)Perforce Client Version$(tput sgr0)" p4 -V | grep Rev. +else + echo "WARNING: perforce wasn't installed, see above for clues why" fi -if type git-lfs >/dev/null +if type git-lfs >/dev/null 2>&1 then echo "$(tput setaf 6)Git-LFS Version$(tput sgr0)" git-lfs version -- 2.36.0-184-gca3de164ba