GNU bug report logs - #73402
Switch scripts from using `type` to `command -v` to support non-XSI POSIX shells, or specify bash?

Previous Next

Package: gzip;

Reported by: Sparr <sparr0 <at> gmail.com>

Date: Sat, 21 Sep 2024 04:08:03 UTC

Severity: normal

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Paul Eggert <eggert <at> cs.ucla.edu>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#73402: closed (Switch scripts from using `type` to `command
 -v` to support non-XSI POSIX shells, or specify bash?)
Date: Sun, 22 Sep 2024 07:10:02 +0000
[Message part 1 (text/plain, inline)]
Your message dated Sun, 22 Sep 2024 00:09:24 -0700
with message-id <e1f830ca-e539-4559-9b6e-dca5b0e5ac94 <at> cs.ucla.edu>
and subject line Re: bug#73402: Switch scripts from using `type` to `command -v` to support non-XSI POSIX shells, or specify bash?
has caused the debbugs.gnu.org bug report #73402,
regarding Switch scripts from using `type` to `command -v` to support non-XSI POSIX shells, or specify bash?
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)


-- 
73402: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=73402
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Sparr <sparr0 <at> gmail.com>
To: bug-gzip <at> gnu.org
Subject: Switch scripts from using `type` to `command -v` to support non-XSI
 POSIX shells, or specify bash?
Date: Fri, 20 Sep 2024 19:10:53 -0400
[Message part 3 (text/plain, inline)]
The `zdiff` and `gzexe` scripts use the `type` command to identify whether
the `mktemp` tool is available. That command exists in XSI-compliant shells
and as an external binary or script in some operating systems, but it is
missing in simple POSIX-compliant shells. Because those scripts start with
`#!/bin/sh` I believe they should work in POSIX-compliant shells. Replacing
the use of `type` with `command -v`, or a more complex construct that uses
`type` when it is available and falls back to `command -v` otherwise, would
allow the scripts to work as intended in those scenarios, rather than
silently failing to find the `mktemp` tool when it is available.

Alternately, if the intent is to only target bash, I would propose the
shebang be changed, although that could have downstream consequences of
introducing a new dependency on systems that don't otherwise need or use
bash.

I apologize if this has been discussed previously. I was not able to find
it in the mailing list archives, but I am also unfamiliar with the
organization of the GNU projects' communication and development channels. I
am sending this email without subscribing to the list because that seems to
be the suggested approach in the docs; please let me know if there is a
better way to address this concern.

--
Sparr
sparr0 <at> gmail.com
http://github.com/sparr
[Message part 4 (text/html, inline)]
[Message part 5 (message/rfc822, inline)]
From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Sparr <sparr0 <at> gmail.com>
Cc: 73402-done <at> debbugs.gnu.org
Subject: Re: bug#73402: Switch scripts from using `type` to `command -v` to
 support non-XSI POSIX shells, or specify bash?
Date: Sun, 22 Sep 2024 00:09:24 -0700
[Message part 6 (text/plain, inline)]
Thanks for the bug report. I installed the attached patch to fix the bug 
and am boldly closing the bug report. If the patch doesn't work for you, 
please let us know and we can reopen the bug report.
[0001-maint-type-command-v.patch (text/x-patch, attachment)]

This bug report was last modified 297 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.