[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#218530: marked as done (Please require that /bin/sh implement "command -v")



Your message dated Sat, 29 Jan 2005 16:56:31 +0100
with message-id <1107014191.1427.130.camel@thanatos>
and subject line More on command -v
has caused the attached Bug report to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what I am
talking about this indicates a serious mail system misconfiguration
somewhere.  Please contact me immediately.)

Debian bug tracking system administrator
(administrator, Debian Bugs database)

--------------------------------------
Received: (at submit) by bugs.debian.org; 31 Oct 2003 23:05:05 +0000
>From ian@davenant.greenend.org.uk Fri Oct 31 17:05:05 2003
Return-path: <ian@davenant.greenend.org.uk>
Received: from chiark.greenend.org.uk [193.201.200.170] 
	by master.debian.org with esmtp (Exim 3.35 1 (Debian))
	id 1AFiKH-0005ox-00; Fri, 31 Oct 2003 17:05:05 -0600
Received: from [172.18.45.6] (helo=davenant.greenend.org.uk ident=mail)
	by chiark.greenend.org.uk (Debian Exim 3.35 #1) with esmtp
	for submit@bugs.debian.org
	id 1AFiKF-0000LM-00; Fri, 31 Oct 2003 23:05:04 +0000
Received: from ian by davenant.greenend.org.uk with local (Exim 3.35 #1)
	id 1AFiKE-0001v2-00 (Debian); Fri, 31 Oct 2003 23:05:02 +0000
From: Ian Jackson <ian@davenant.greenend.org.uk>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Message-ID: <16290.60062.866191.173443@davenant.relativity.greenend.org.uk>
Date: Fri, 31 Oct 2003 23:05:02 +0000
To: submit@bugs.debian.org
Subject: Suboptimal conditional rune for initscripts
X-Mailer: VM 7.03 under Emacs 19.34.1
Delivered-To: submit@bugs.debian.org
X-Spam-Status: No, hits=-5.0 required=4.0
	tests=HAS_PACKAGE
	version=2.53-bugs.debian.org_2003_10_31
X-Spam-Level: 
X-Spam-Checker-Version: SpamAssassin 2.53-bugs.debian.org_2003_10_31 (1.174.2.15-2003-03-30-exp)

Package: debian-policy
Version: 3.6.1.0

While trying to merge an NMU to my package, I spotted an idiom
obviously copied from the policy manual:

        if [ -x /usr/sbin/invoke-rc.d ] ; then
		invoke-rc.d package <action>
        else
		/etc/init.d/package <action>
	fi

This would be better expressed as

	if type -p invoke-rc.d >/dev/null 2>&1; then
	...

This latter form will detect accurately whether invoke-rc.d is
available _on the current PATH_ as set by the sysadmin, and will
therefore allow somewhat greater flexibility to admins (eg, to install
invoke-rc.d separately in /usr/local before upgrading).

Ian.

---------------------------------------
Received: (at 218530-done) by bugs.debian.org; 29 Jan 2005 15:58:26 +0000
>From jdthood@aglu.demon.nl Sat Jan 29 07:58:26 2005
Return-path: <jdthood@aglu.demon.nl>
Received: from mailservice.tudelft.nl [130.161.131.5] 
	by spohr.debian.org with esmtp (Exim 3.35 1 (Debian))
	id 1CuuzS-00054L-00; Sat, 29 Jan 2005 07:58:26 -0800
Received: from localhost (localhost [127.0.0.1])
	by rav.antivirus (Postfix) with ESMTP id A3D86233661;
	Sat, 29 Jan 2005 16:57:55 +0100 (CET)
Received: from localhost (x123.decis.nl [130.161.177.123])
	by mx2.tudelft.nl (Postfix) with ESMTP id 24488233660;
	Sat, 29 Jan 2005 16:57:54 +0100 (CET)
Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
	by localhost (Postfix) with ESMTP id 59CCC10D5FD;
	Sat, 29 Jan 2005 16:56:32 +0100 (CET)
Subject: More on command -v
From: Thomas Hood <jdthood@aglu.demon.nl>
To: 291197-quiet@bugs.debian.org, 218530-done@bugs.debian.org
Content-Type: text/plain
Date: Sat, 29 Jan 2005 16:56:31 +0100
Message-Id: <1107014191.1427.130.camel@thanatos>
Mime-Version: 1.0
X-Mailer: Evolution 2.0.3 
Content-Transfer-Encoding: 7bit
X-Virus-Scanned: by amavisd-new at tudelft.nl
Delivered-To: 218530-done@bugs.debian.org
X-Spam-Checker-Version: SpamAssassin 2.60-bugs.debian.org_2005_01_02 
	(1.212-2003-09-23-exp) on spohr.debian.org
X-Spam-Status: No, hits=-5.0 required=4.0 tests=BAYES_00,VALID_BTS_CONTROL 
	autolearn=no version=2.60-bugs.debian.org_2005_01_02
X-Spam-Level: 
X-CrossAssassin-Score: 2

tags 291197 wontfix
thanks


I wrote:
> if [ -x "$(command -v foo 2>/dev/null)" ] ; then

This method of testing whether foo is executable fails if foo is a shell
function because [ -x "foo" ] tests the executability of ./foo rather
than the foo on the PATH.  This problem is discussed further at #291026.
My conclusion is that "command -v foo" is of limited usefulness for
checking whether or not foo is really executable.  Tollef Fog Heen's
findcommand() function in #218530 is a better way to search for
executable programs on the PATH, whereas going ahead and trying foo

    foo || case "$?" in 126|127) do_alternative_to_foo ;; esac

is a better way to test whether or not foo (whether function, builtin or
executable program on the PATH) can really be executed.  Consequently I
am closing my wish #218530 since there seems to be no point in
requiring /bin/sh to implement command -v.

-- 
Thomas Hood <jdthood@aglu.demon.nl>



Reply to: