On 4/22/25 11:55 AM, Junio C Hamano wrote: > Phillip Wood <phillip.wood123@xxxxxxxxx> writes: > >> I'd be tempted to check for which package manager to use by using >> `command -v`. That way the only distribution specific knowledge we >> need is the package manager and we don't have to worry about the names >> of the various release files in /etc. >> >> if command -v git >> then >> : nothing to do >> elif command -v apk >> then >> apk add git >> elif command -v dnf >> then >> dnf -y install git >> else >> apt-get -q -y install git >> fi > > OK. "command -v" should be portable enough these days (in the past > people used "type" and yelled at by portability sherriff). It (command -v) is available since POSIX 2008, yes. Optional before that, and thus available in many (but not all) contexts. Debian upgraded from POSIX 2001 to POSIX 2008, as of July 2018, see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=864615 Quotable quote: """ This version of the standard is so outdated that it isn't even any longer available on the opengroup web site. [...] Please consider updating the policy. """ -- Eli Schwartz
Attachment:
OpenPGP_signature.asc
Description: OpenPGP digital signature