git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2 1/2] ci: make failure to find perforce more user friendly

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 22, 2022, 22:23 UTC
Message-ID
<xmqq5yn069lq.fsf@gitster.g>
In-Reply-To
<xmqqo80td5wj.fsf@gitster.g>
Junio C Hamano <gitster@pobox.com> writes:
Show 12 quoted lines
> 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@gmail.com>

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@sunshineco.com>
Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 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
Previous: Junio C HamanoNext: Carlo Arenas
Message 7 of 26 in “ci: make perforce installation optional in macOS”
  1. ci: make perforce installation optional in macOSCarlo Marcelo Arenas Belón, Apr 21, 2022
  2. Eric SunshineApr 21, 2022
  3. Eric SunshineApr 21, 2022
  4. 0/2 ci: avoid perforce/brew issues affecting macOSCarlo Marcelo Arenas Belón, Apr 22, 2022
  5. 1/2 ci: make failure to find perforce more user friendlyCarlo Marcelo Arenas Belón, Apr 22, 2022
  6. Junio C HamanoApr 22, 2022
  7. Junio C HamanoApr 22, 2022
  8. Carlo ArenasApr 22, 2022
  9. Junio C HamanoApr 22, 2022
  10. Carlo ArenasApr 23, 2022
  11. 2/2 ci: make perforce installation optional in macOSCarlo Marcelo Arenas Belón, Apr 22, 2022
  12. 0/4 ci: avoid perforce/brew issues affecting macOSCarlo Marcelo Arenas Belón, Apr 23, 2022
  13. 1/4 ci: make failure to find perforce more user friendlyCarlo Marcelo Arenas Belón, Apr 23, 2022
  14. Junio C HamanoApr 26, 2022
  15. 3/4 ci: reintroduce prevention from perforce being quarantined in macOSCarlo Marcelo Arenas Belón, Apr 23, 2022
  16. Eric SunshineApr 24, 2022
  17. 4/4 CI: use https, not http to download binaries from perforce.comCarlo Marcelo Arenas Belón, Apr 23, 2022
  18. 2/4 ci: avoid brew for installing perforceCarlo Marcelo Arenas Belón, Apr 23, 2022
  19. Eric SunshineApr 24, 2022
  20. Johannes SchindelinApr 26, 2022
  21. Carlo ArenasApr 26, 2022
  22. 0/4 ci: avoid perforce/brew issues affecting macOSJunio C Hamano, May 12, 2022
  23. 1/4 ci: make failure to find perforce more user friendlyJunio C Hamano, May 12, 2022
  24. 2/4 ci: avoid brew for installing perforceJunio C Hamano, May 12, 2022
  25. 3/4 ci: reintroduce prevention from perforce being quarantined in macOSJunio C Hamano, May 12, 2022
  26. 4/4 ci: use https, not http to download binaries from perforce.comJunio C Hamano, May 12, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.