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

Bug#291026: marked as done ( "command -v" example needs tweaking)

Your message dated Sat, 18 Jun 2005 00:15:46 -0500
with message-id <87slzgnt31.fsf@glaurung.internal.golden-gryphon.com>
and subject line Why is this a bug?
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; 18 Jan 2005 09:49:57 +0000
>From jdthood@aglu.demon.nl Tue Jan 18 01:49:57 2005
Return-path: <jdthood@aglu.demon.nl>
Received: from mailservice.tudelft.nl [] 
	by spohr.debian.org with esmtp (Exim 3.35 1 (Debian))
	id 1Cqpzo-0000t9-00; Tue, 18 Jan 2005 01:49:56 -0800
Received: from localhost (localhost [])
	by rav.antivirus (Postfix) with ESMTP id 2F9C122EEEA;
	Tue, 18 Jan 2005 10:49:25 +0100 (CET)
Received: from localhost (x117.decis.nl [])
	by mx1.tudelft.nl (Postfix) with ESMTP id 822D722EF87;
	Tue, 18 Jan 2005 10:49:24 +0100 (CET)
Received: by localhost (Postfix, from userid 1001)
	id 3E6B610D5CD; Tue, 18 Jan 2005 10:48:58 +0100 (CET)
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
From: Thomas Hood <jdthood@aglu.demon.nl>
To: Debian Bug Tracking System <submit@bugs.debian.org>
Subject: "command -v" example needs tweaking
X-Mailer: reportbug 3.2
Date: Tue, 18 Jan 2005 10:48:57 +0100
Message-Id: <20050118094858.3E6B610D5CD@localhost>
X-Virus-Scanned: by amavisd-new at tudelft.nl
Delivered-To: submit@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=-8.0 required=4.0 tests=BAYES_00,HAS_PACKAGE 
	autolearn=no version=2.60-bugs.debian.org_2005_01_02

Package: debian-policy
Severity: minor

Section gives this as an example of how to check for the
availability of invoke-rc.d:

>    if command -v invoke-rc.d >/dev/null 2>&1; then

1. It would be helpful to mention that "command -v" is not POSIX and
   that therefore, to be consistent with section 10.4, this example
   should only be followed in scripts headed with "#!/bin/bash".

   If #218530 is ever implemented then this restriction can be

2. "command -v" in bash 3.0-5 sometimes prints pathnames of files
   on the PATH that aren't executable.  To work around this, the
   example could be changed to something like this:

    if CMD="$(command -v invoke-rc.d 2>/dev/null)" && [ -x "$CMD" ] ; then

I actually think that issue #2 is a bug in bash. Consider the following
sequence of commands which illustrate that "command -v foo" prints
the name of the first executable file "foo" it finds on the PATH,
failing which it prints the first non-executable file "foo" it finds
on the PATH.  What sense does that make?  If people agree then I'll
file a bug report against bash.

jdthood@thanatos:~$ echo $PATH
jdthood@thanatos:~$ which foo
jdthood@thanatos:~$ command -v foo
bash: command: foo: not found
jdthood@thanatos:~$ touch /home/jdthood/bin/foo
jdthood@thanatos:~$ ls -l /home/jdthood/bin/foo
-rw-r--r--  1 jdthood jdthood 0 2005-01-18 10:40 /home/jdthood/bin/foo
jdthood@thanatos:~$ which foo
jdthood@thanatos:~$ command -v foo
jdthood@thanatos:~$ sudo touch /usr/local/bin/foo
jdthood@thanatos:~$ which foo
jdthood@thanatos:~$ command -v foo
jdthood@thanatos:~$ ls -l /usr/local/bin/foo
-rw-r--r--  1 root staff 0 2005-01-18 10:41 /usr/local/bin/foo
jdthood@thanatos:~$ sudo chmod ugo+x /usr/local/bin/foo
jdthood@thanatos:~$ ls -l /usr/local/bin/foo
-rwxr-xr-x  1 root staff 0 2005-01-18 10:41 /usr/local/bin/foo
jdthood@thanatos:~$ which foo
jdthood@thanatos:~$ command -v foo

-- System Information:
Debian Release: 3.1
  APT prefers testing
  APT policy: (500, 'testing'), (50, 'unstable'), (1, 'experimental')
Architecture: i386 (i686)
Kernel: Linux 2.6.9
Locale: LANG=en_IE@euro, LC_CTYPE=en_IE@euro (charmap=ISO-8859-15)

-- no debconf information

Received: (at 291026-done) by bugs.debian.org; 18 Jun 2005 05:25:37 +0000
>From srivasta@debian.org Fri Jun 17 22:25:37 2005
Return-path: <srivasta@debian.org>
Received: from host-12-107-230-171.dtccom.net (glaurung.internal.golden-gryphon.com) [] 
	by spohr.debian.org with esmtp (Exim 3.35 1 (Debian))
	id 1DjVpp-0004zu-00; Fri, 17 Jun 2005 22:25:37 -0700
Received: from glaurung.internal.golden-gryphon.com (srivasta@localhost [])
	by glaurung.internal.golden-gryphon.com (8.13.4/8.13.4/Debian-3) with ESMTP id j5I5FkkW013934
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT)
	for <291026-done@bugs.debian.org>; Sat, 18 Jun 2005 00:15:46 -0500
Received: (from srivasta@localhost)
	by glaurung.internal.golden-gryphon.com (8.13.4/8.13.4/Submit) id j5I5Fkkp013933;
	Sat, 18 Jun 2005 00:15:46 -0500
X-Authentication-Warning: glaurung.internal.golden-gryphon.com: srivasta set sender to srivasta(va, manoj)@debian.org using -f
From: Manoj Srivastava <srivasta@debian.org (va, manoj)>
To: 291026-done@bugs.debian.org
Subject: Why is this a bug?
Organization: The Debian Project
User-Agent: Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.50 (gnu/linux) (i686-pc-linux-gnu)
X-URL: http://www.debian.org/%7Esrivasta/
Mail-Copies-To: nobody
X-Face: #q.#]5@vq!Jz+E0t_/;Y^gTjR\T^"B'fbeuVGiyKrvbfKJl!^e|e:iu(kJ6c|QYB57LP*|t
X-Hashcash: 1:25:050618:291026-done@bugs.debian.org::+LNy0C4CMfnLgD7J:0000000000000000000000000000000002P+dm
Date: Sat, 18 Jun 2005 00:15:46 -0500
Message-ID: <87slzgnt31.fsf@glaurung.internal.golden-gryphon.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-CRM114-Score: -13.1141
X-CRM114-Status: Good  ( pR: -13.1141 )
X-SA-Orig: -9.899, -13.1141
X-Spam-Value: -15.0720055555556
X-Grey: White
X-SA-Rep: -15.0720055555556 ALL_TRUSTED,BAYES_00,HASHCASH_25
X-Scanned-By: MIMEDefang version 2.51 (www . roaringpenguin . com / mimedefang) on
Delivered-To: 291026-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=-3.0 required=4.0 tests=BAYES_00 autolearn=no 


        Why should policy example follow some other code out there,
 especially if the examples shown in policy are correct?  And it has
 not been shown that which messes up, command -v would work
 differently, but not which.

        Seems to me debhelper is doing an extra, unneeded stat, which
 is fine. I  see no reason to emulate that, though, in an example.

There is nothing wrong with writing ... as long as it is done in
private and you wash your hands afterward.
Manoj Srivastava   <srivasta@debian.org>  <http://www.debian.org/%7Esrivasta/>
1024D/BF24424C print 4966 F272 D093 B493 410B  924B 21BA DABB BF24 424C

Reply to: