Debian Bug report logs - #580492
busybox basename/dirname should discard the first arg when it is --

version graph

Package: busybox; Maintainer for busybox is Debian Install System Team <debian-boot@lists.debian.org>; Source for busybox is src:busybox.

Reported by: Vincent Lefevre <vincent@vinc17.net>

Date: Thu, 6 May 2010 11:03:01 UTC

Severity: important

Tags: patch, upstream

Fixed in version busybox/1:1.18.4-1

Done: Michael Tokarev <mjt@tls.msk.ru>

Bug is archived. No further changes may be made.

Toggle useless messages

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to debian-bugs-dist@lists.debian.org, Michael Stone <mstone@debian.org>:
Bug#580492; Package coreutils. (Thu, 06 May 2010 11:03:04 GMT) Full text and rfc822 format available.

Acknowledgement sent to Vincent Lefevre <vincent@vinc17.net>:
New Bug report received and forwarded. Copy sent to Michael Stone <mstone@debian.org>. (Thu, 06 May 2010 11:03:04 GMT) Full text and rfc822 format available.

Message #5 received at submit@bugs.debian.org (full text, mbox):

From: Vincent Lefevre <vincent@vinc17.net>
To: Debian Bug Tracking System <submit@bugs.debian.org>
Subject: coreutils: basename/dirname are not POSIX compliant on arg starting with a dash
Date: Thu, 6 May 2010 12:59:58 +0200
Package: coreutils
Version: 8.5-1
Severity: normal
Tags: upstream

With the basename and dirname utilities from GNU Coreutils, one has:

ypig% POSIXLY_CORRECT=1 basename --
basename: missing operand
Try `basename --help' for more information.
ypig% POSIXLY_CORRECT=1 dirname --
dirname: missing operand
Try `dirname --help' for more information.

instead of:

ypig% busybox basename --
--
ypig% busybox dirname --
.

According to POSIX[*], basename and dirname take no options (examples
in POSIX also assume that), so that this would make BusyBox's behavior
correct.

[*] http://www.opengroup.org/onlinepubs/9699919799/utilities/basename.html
    http://www.opengroup.org/onlinepubs/9699919799/utilities/dirname.html

-- System Information:
Debian Release: squeeze/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'testing')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.32-3-amd64 (SMP w/8 CPU cores)
Locale: LANG=POSIX, LC_CTYPE=en_US.ISO8859-1 (charmap=ISO-8859-1)
Shell: /bin/sh linked to /bin/dash

Versions of packages coreutils depends on:
ii  libacl1                       2.2.49-2   Access control list shared library
ii  libattr1                      1:2.4.44-1 Extended attribute shared library
ii  libc6                         2.10.2-7   Embedded GNU C Library: Shared lib
ii  libselinux1                   2.0.94-1   SELinux runtime shared libraries

coreutils recommends no packages.

coreutils suggests no packages.

-- no debconf information




Information forwarded to debian-bugs-dist@lists.debian.org, Michael Stone <mstone@debian.org>:
Bug#580492; Package coreutils. (Thu, 06 May 2010 11:18:05 GMT) Full text and rfc822 format available.

Acknowledgement sent to Vincent Lefevre <vincent@vinc17.net>:
Extra info received and forwarded to list. Copy sent to Michael Stone <mstone@debian.org>. (Thu, 06 May 2010 11:18:05 GMT) Full text and rfc822 format available.

Message #10 received at 580492@bugs.debian.org (full text, mbox):

From: Vincent Lefevre <vincent@vinc17.net>
To: bug-coreutils@gnu.org
Cc: 580492@bugs.debian.org
Subject: basename/dirname are not POSIX compliant on arg starting with a dash
Date: Thu, 6 May 2010 13:15:02 +0200
Hi,

I've reported the following bug in the Debian BTS:

  http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=580492

With the basename and dirname utilities from GNU Coreutils, one has:

ypig% POSIXLY_CORRECT=1 basename --
basename: missing operand
Try `basename --help' for more information.
ypig% POSIXLY_CORRECT=1 dirname --
dirname: missing operand
Try `dirname --help' for more information.

instead of:

ypig% busybox basename --
--
ypig% busybox dirname --
.

According to POSIX[*], basename and dirname take no options (examples
in POSIX also assume that), so that this would make BusyBox's behavior
correct.

[*] http://www.opengroup.org/onlinepubs/9699919799/utilities/basename.html
    http://www.opengroup.org/onlinepubs/9699919799/utilities/dirname.html

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / Arénaire project (LIP, ENS-Lyon)




Information forwarded to debian-bugs-dist@lists.debian.org, Michael Stone <mstone@debian.org>:
Bug#580492; Package coreutils. (Thu, 06 May 2010 11:33:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Vincent Lefevre <vincent@vinc17.net>:
Extra info received and forwarded to list. Copy sent to Michael Stone <mstone@debian.org>. (Thu, 06 May 2010 11:33:02 GMT) Full text and rfc822 format available.

Message #15 received at 580492@bugs.debian.org (full text, mbox):

From: Vincent Lefevre <vincent@vinc17.net>
To: bug-coreutils@gnu.org, 580492@bugs.debian.org
Subject: Re: basename/dirname are not POSIX compliant on arg starting with a dash
Date: Thu, 6 May 2010 13:31:45 +0200
A practical example of a failure could be when one uses

  dirname "$0"

in a rc file and the shell happens to be a login shell.

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / Arénaire project (LIP, ENS-Lyon)




Information forwarded to debian-bugs-dist@lists.debian.org:
Bug#580492; Package coreutils. (Thu, 06 May 2010 12:21:06 GMT) Full text and rfc822 format available.

Acknowledgement sent to Michael Stone <mstone@debian.org>:
Extra info received and forwarded to list. (Thu, 06 May 2010 12:21:06 GMT) Full text and rfc822 format available.

Message #20 received at 580492@bugs.debian.org (full text, mbox):

From: Michael Stone <mstone@debian.org>
To: Vincent Lefevre <vincent@vinc17.net>, bug-coreutils@gnu.org, 580492@bugs.debian.org
Subject: Re: Bug#580492: basename/dirname are not POSIX compliant on arg starting with a dash
Date: Thu, 06 May 2010 08:16:50 -0400
On Thu, May 06, 2010 at 01:31:45PM +0200, you wrote:
>A practical example of a failure could be when one uses
>
>  dirname "$0"
>
>in a rc file and the shell happens to be a login shell.

I'm not convinced of this interpretation, and suspect that 
dirname -- "$@"
would be more portable. 

Mike Stone




Information forwarded to debian-bugs-dist@lists.debian.org, Michael Stone <mstone@debian.org>:
Bug#580492; Package coreutils. (Thu, 06 May 2010 13:00:10 GMT) Full text and rfc822 format available.

Acknowledgement sent to Pádraig Brady <P@draigBrady.com>:
Extra info received and forwarded to list. Copy sent to Michael Stone <mstone@debian.org>. (Thu, 06 May 2010 13:00:10 GMT) Full text and rfc822 format available.

Message #25 received at 580492@bugs.debian.org (full text, mbox):

From: Pádraig Brady <P@draigBrady.com>
To: Vincent Lefevre <vincent@vinc17.net>, bug-coreutils@gnu.org, 580492@bugs.debian.org
Subject: Re: bug#6124: basename/dirname are not POSIX compliant on arg starting with a dash
Date: Thu, 06 May 2010 13:50:27 +0100
On 06/05/10 12:15, Vincent Lefevre wrote:
> Hi,
> 
> I've reported the following bug in the Debian BTS:
> 
>   http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=580492
> 
> With the basename and dirname utilities from GNU Coreutils, one has:
> 
> ypig% POSIXLY_CORRECT=1 basename --
> basename: missing operand
> Try `basename --help' for more information.
> ypig% POSIXLY_CORRECT=1 dirname --
> dirname: missing operand
> Try `dirname --help' for more information.
> 
> instead of:
> 
> ypig% busybox basename --
> --
> ypig% busybox dirname --
> .
> 
> According to POSIX[*], basename and dirname take no options (examples
> in POSIX also assume that), so that this would make BusyBox's behavior
> correct.
> 
> [*] http://www.opengroup.org/onlinepubs/9699919799/utilities/basename.html
>     http://www.opengroup.org/onlinepubs/9699919799/utilities/dirname.html
> 

The above busybox behavior implies that
if you write a robust script like this for coreutils,
that it is not portable to busybox:

base=$(basename -- "$path")

That also implies that we can't change the behavior.
Because there is an optional suffix parameter, one can't
know which behavior is required for the above example.
I suppose one could choose based on POSIXLY_CORRECT.

Note solaris behaves like busybox and openbsd behaves like coreutils.

cheers,
Pádraig.




Information forwarded to debian-bugs-dist@lists.debian.org:
Bug#580492; Package coreutils. (Thu, 06 May 2010 13:12:05 GMT) Full text and rfc822 format available.

Acknowledgement sent to Michael Stone <mstone@debian.org>:
Extra info received and forwarded to list. (Thu, 06 May 2010 13:12:05 GMT) Full text and rfc822 format available.

Message #30 received at 580492@bugs.debian.org (full text, mbox):

From: Michael Stone <mstone@debian.org>
To: Pádraig Brady <P@draigBrady.com>, 580492@bugs.debian.org
Cc: Vincent Lefevre <vincent@vinc17.net>, bug-coreutils@gnu.org
Subject: Re: Bug#580492: bug#6124: basename/dirname are not POSIX compliant on arg starting with a dash
Date: Thu, 06 May 2010 09:08:53 -0400
On Thu, May 06, 2010 at 01:50:27PM +0100, Pádraig Brady wrote:
>The above busybox behavior implies that
>if you write a robust script like this for coreutils,
>that it is not portable to busybox:
>
>base=$(basename -- "$path")

Yup, I'd suggest busybox should change. :-)

>Note solaris behaves like busybox and openbsd behaves like coreutils.

freebsd & OSX also use the existing coreutils behavior. So that's most 
of the deployed unixbase at this point.

Mike Stone





Information forwarded to debian-bugs-dist@lists.debian.org, Michael Stone <mstone@debian.org>:
Bug#580492; Package coreutils. (Thu, 06 May 2010 13:27:18 GMT) Full text and rfc822 format available.

Acknowledgement sent to Vincent Lefevre <vincent@vinc17.net>:
Extra info received and forwarded to list. Copy sent to Michael Stone <mstone@debian.org>. (Thu, 06 May 2010 13:27:18 GMT) Full text and rfc822 format available.

Message #35 received at 580492@bugs.debian.org (full text, mbox):

From: Vincent Lefevre <vincent@vinc17.net>
To: Pádraig Brady <P@draigBrady.com>
Cc: bug-coreutils@gnu.org, 580492@bugs.debian.org
Subject: Re: bug#6124: basename/dirname are not POSIX compliant on arg starting with a dash
Date: Thu, 6 May 2010 15:23:38 +0200
On 2010-05-06 13:50:27 +0100, Pádraig Brady wrote:
> The above busybox behavior implies that
> if you write a robust script like this for coreutils,
> that it is not portable to busybox:
> 
> base=$(basename -- "$path")

If one follows POSIX, the correct way to do it is:

  base=$(basename "$path")

and this is robust because the first argument is necessarily the path
(it cannot be an option, even "--").

> That also implies that we can't change the behavior.

According to

  grep 'basename --' /usr/bin/*
  grep 'basename \$' /usr/bin/*

on my Debian machine, almost all scripts use basename without "--".
The only exceptions are autoconf (but I'm not sure this counts, as
there's a test for "basename --" first, and I don't know what it
really expects) and savelog (from the debianutils package, thus
specific to Debian, but savelog also uses `basename $0`, so that
it is already inconsistent). Therefore I assume that changing
coreutils would be easier.

> Because there is an optional suffix parameter, one can't
> know which behavior is required for the above example.
> I suppose one could choose based on POSIXLY_CORRECT.

I think that it should really behave correctly if POSIXLY_CORRECT
is set, but also if it isn't set, given what appears to be the
current practice.

> Note solaris behaves like busybox and openbsd behaves like coreutils.

Perhaps they're copying coreutils without looking at what POSIX says.

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / Arénaire project (LIP, ENS-Lyon)




Information forwarded to debian-bugs-dist@lists.debian.org, Michael Stone <mstone@debian.org>:
Bug#580492; Package coreutils. (Thu, 06 May 2010 13:33:05 GMT) Full text and rfc822 format available.

Acknowledgement sent to Vincent Lefevre <vincent@vinc17.net>:
Extra info received and forwarded to list. Copy sent to Michael Stone <mstone@debian.org>. (Thu, 06 May 2010 13:33:05 GMT) Full text and rfc822 format available.

Message #40 received at 580492@bugs.debian.org (full text, mbox):

From: Vincent Lefevre <vincent@vinc17.net>
To: Michael Stone <mstone@debian.org>
Cc: bug-coreutils@gnu.org, 580492@bugs.debian.org
Subject: Re: Bug#580492: basename/dirname are not POSIX compliant on arg starting with a dash
Date: Thu, 6 May 2010 15:29:05 +0200
On 2010-05-06 08:16:50 -0400, Michael Stone wrote:
> On Thu, May 06, 2010 at 01:31:45PM +0200, you wrote:
> >A practical example of a failure could be when one uses
> >
> > dirname "$0"
> >
> >in a rc file and the shell happens to be a login shell.
> 
> I'm not convinced of this interpretation, and suspect that dirname
> -- "$@" would be more portable.

This doesn't work with BusyBox, where dirname fails if there isn't
*exactly* one argument. So, this can only be: dirname "$0"

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / Arénaire project (LIP, ENS-Lyon)




Information forwarded to debian-bugs-dist@lists.debian.org, Michael Stone <mstone@debian.org>:
Bug#580492; Package coreutils. (Thu, 06 May 2010 13:45:09 GMT) Full text and rfc822 format available.

Acknowledgement sent to Eric Blake <eblake@redhat.com>:
Extra info received and forwarded to list. Copy sent to Michael Stone <mstone@debian.org>. (Thu, 06 May 2010 13:45:09 GMT) Full text and rfc822 format available.

Message #45 received at 580492@bugs.debian.org (full text, mbox):

From: Eric Blake <eblake@redhat.com>
To: Vincent Lefevre <vincent@vinc17.net>, bug-coreutils@gnu.org, 580492@bugs.debian.org
Subject: Re: bug#6124: basename/dirname are not POSIX compliant on arg starting with a dash
Date: Thu, 06 May 2010 07:41:59 -0600
[Message part 1 (text/plain, inline)]
On 05/06/2010 05:15 AM, Vincent Lefevre wrote:
> Hi,
> 
> I've reported the following bug in the Debian BTS:
> 
>   http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=580492

That bug should be reassigned to busybox.

> 
> With the basename and dirname utilities from GNU Coreutils, one has:
> 
> ypig% POSIXLY_CORRECT=1 basename --
> basename: missing operand

Correct.

> 
> ypig% busybox basename --
> --

Buggy.

> According to POSIX[*], basename and dirname take no options (examples
> in POSIX also assume that), so that this would make BusyBox's behavior
> correct.

No, you're missing one other key point of POSIX:

http://www.opengroup.org/onlinepubs/9699919799/utilities/V3_chap01.html
Section 1.4, OPTIONS:

    Default Behavior: When this section is listed as "None.", it means
that the implementation need not support any options. Standard utilities
that do not accept options, but that do accept operands, shall recognize
"--" as a first argument to be discarded.

    The requirement for recognizing "--" is because conforming
applications need a way to shield their operands from any arbitrary
options that the implementation may provide as an extension. For
example, if the standard utility foo is listed as taking no options, and
the application needed to give it a pathname with a leading <hyphen>, it
could safely do it as:

    foo -- -myfile

    and avoid any problems with -m used as an extension.

-- 
Eric Blake   eblake@redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

[signature.asc (application/pgp-signature, attachment)]

Information forwarded to debian-bugs-dist@lists.debian.org, Michael Stone <mstone@debian.org>:
Bug#580492; Package coreutils. (Thu, 06 May 2010 13:51:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Jim Meyering <jim@meyering.net>:
Extra info received and forwarded to list. Copy sent to Michael Stone <mstone@debian.org>. (Thu, 06 May 2010 13:51:03 GMT) Full text and rfc822 format available.

Message #50 received at 580492@bugs.debian.org (full text, mbox):

From: Jim Meyering <jim@meyering.net>
To: Vincent Lefevre <vincent@vinc17.net>
Cc: bug-coreutils@gnu.org, 580492@bugs.debian.org
Subject: Re: Bug#580492: basename/dirname are not POSIX compliant on arg starting with a dash
Date: Thu, 06 May 2010 15:41:19 +0200
Vincent Lefevre wrote:
> I've reported the following bug in the Debian BTS:
>
>   http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=580492
>
> With the basename and dirname utilities from GNU Coreutils, one has:
>
> ypig% POSIXLY_CORRECT=1 basename --
> basename: missing operand
> Try `basename --help' for more information.
> ypig% POSIXLY_CORRECT=1 dirname --
> dirname: missing operand
> Try `dirname --help' for more information.
>
> instead of:
>
> ypig% busybox basename --
> --
> ypig% busybox dirname --
> .
...

Hi Vincent,

Thanks for the suggestion, but I suggest you
take it up on the austin-group mailing list.

This recent change suggests that the coreutils behavior
is what POSIX intends:

    http://austingroupbugs.net/view.php?id=192#c324




Information forwarded to debian-bugs-dist@lists.debian.org, Michael Stone <mstone@debian.org>:
Bug#580492; Package coreutils. (Thu, 06 May 2010 13:51:04 GMT) Full text and rfc822 format available.

Acknowledgement sent to Eric Blake <eblake@redhat.com>:
Extra info received and forwarded to list. Copy sent to Michael Stone <mstone@debian.org>. (Thu, 06 May 2010 13:51:04 GMT) Full text and rfc822 format available.

Message #55 received at 580492@bugs.debian.org (full text, mbox):

From: Eric Blake <eblake@redhat.com>
Cc: Vincent Lefevre <vincent@vinc17.net>, bug-coreutils@gnu.org, 580492@bugs.debian.org
Subject: Re: bug#6124: basename/dirname are not POSIX compliant on arg starting with a dash
Date: Thu, 06 May 2010 07:49:31 -0600
[Message part 1 (text/plain, inline)]
On 05/06/2010 07:41 AM, Eric Blake wrote:
>> According to POSIX[*], basename and dirname take no options (examples
>> in POSIX also assume that), so that this would make BusyBox's behavior
>> correct.
> 
> No, you're missing one other key point of POSIX:
> 
> http://www.opengroup.org/onlinepubs/9699919799/utilities/V3_chap01.html
> Section 1.4, OPTIONS:

If you want more evidence from POSIX that 'basename -- foo' is mandated
behavior, read up on this correction to POSIX:
http://austingroupbugs.net/view.php?id=192

-- 
Eric Blake   eblake@redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

[signature.asc (application/pgp-signature, attachment)]

Information forwarded to debian-bugs-dist@lists.debian.org, Michael Stone <mstone@debian.org>:
Bug#580492; Package coreutils. (Thu, 06 May 2010 14:06:06 GMT) Full text and rfc822 format available.

Acknowledgement sent to Eric Blake <eblake@redhat.com>:
Extra info received and forwarded to list. Copy sent to Michael Stone <mstone@debian.org>. (Thu, 06 May 2010 14:06:06 GMT) Full text and rfc822 format available.

Message #60 received at 580492@bugs.debian.org (full text, mbox):

From: Eric Blake <eblake@redhat.com>
To: Vincent Lefevre <vincent@vinc17.net>, Pádraig Brady <P@draigBrady.com>, bug-coreutils@gnu.org, 580492@bugs.debian.org
Subject: Re: bug#6124: basename/dirname are not POSIX compliant on arg starting with a dash
Date: Thu, 06 May 2010 08:02:04 -0600
[Message part 1 (text/plain, inline)]
On 05/06/2010 07:23 AM, Vincent Lefevre wrote:
> If one follows POSIX, the correct way to do it is:
> 
>   base=$(basename "$path")
> 
> and this is robust because the first argument is necessarily the path
> (it cannot be an option, even "--").

POSIX does not forbid applications from adding extension options.  And
BSD basename has done just that:

SYNOPSIS
     basename string [suffix]
     basename [-a] [-s suffix] string [...]
     dirname string [...]

And since POSIX allows FreeBSD's extensions to exist (although a
portable script will not use them), it must also require that a portable
app be able to guarantee a way to bypass those extensions (ergo
base=$(basename -- "$path") is a POSIX requirement).

> According to
> 
>   grep 'basename --' /usr/bin/*
>   grep 'basename \$' /usr/bin/*
> 
> on my Debian machine, almost all scripts use basename without "--".
> The only exceptions are autoconf (but I'm not sure this counts, as
> there's a test for "basename --" first,

Can you find an actual example of this?  I think you read it
incorrectly, as really, autoconf first tests for 'basename -- /', but if
you indeed found an instance of autoconf testing for 'basename --', that
would be a bug in autoconf that needs to be reported to that list.

>> Note solaris behaves like busybox and openbsd behaves like coreutils.
> 
> Perhaps they're copying coreutils without looking at what POSIX says.

Or, more likely, perhaps they are independently obeying what POSIX says,
without reference to either coreutils or busybox.

-- 
Eric Blake   eblake@redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

[signature.asc (application/pgp-signature, attachment)]

Information forwarded to debian-bugs-dist@lists.debian.org:
Bug#580492; Package coreutils. (Thu, 06 May 2010 14:21:10 GMT) Full text and rfc822 format available.

Acknowledgement sent to Michael Stone <mstone@debian.org>:
Extra info received and forwarded to list. (Thu, 06 May 2010 14:21:10 GMT) Full text and rfc822 format available.

Message #65 received at 580492@bugs.debian.org (full text, mbox):

From: Michael Stone <mstone@debian.org>
To: Vincent Lefevre <vincent@vinc17.net>, bug-coreutils@gnu.org, 580492@bugs.debian.org
Subject: Re: Bug#580492: basename/dirname are not POSIX compliant on arg starting with a dash
Date: Thu, 06 May 2010 10:18:05 -0400
On Thu, May 06, 2010 at 03:29:05PM +0200, you wrote:
>On 2010-05-06 08:16:50 -0400, Michael Stone wrote:
>> I'm not convinced of this interpretation, and suspect that dirname
>> -- "$@" would be more portable.
>
>This doesn't work with BusyBox, where dirname fails if there isn't
>*exactly* one argument. So, this can only be: dirname "$0"

I understand that, which I why I suggested that busybox change. AFAICT 
the vast majority of (living) implementations don't behave the way 
you're suggesting they should, and it seems unlikely that all of them 
will change.

Mike Stone




Information forwarded to debian-bugs-dist@lists.debian.org, Michael Stone <mstone@debian.org>:
Bug#580492; Package coreutils. (Thu, 06 May 2010 14:27:09 GMT) Full text and rfc822 format available.

Acknowledgement sent to Vincent Lefevre <vincent@vinc17.net>:
Extra info received and forwarded to list. Copy sent to Michael Stone <mstone@debian.org>. (Thu, 06 May 2010 14:27:09 GMT) Full text and rfc822 format available.

Message #70 received at 580492@bugs.debian.org (full text, mbox):

From: Vincent Lefevre <vincent@vinc17.net>
To: Eric Blake <eblake@redhat.com>
Cc: bug-coreutils@gnu.org, 580492@bugs.debian.org
Subject: Re: bug#6124: basename/dirname are not POSIX compliant on arg starting with a dash
Date: Thu, 6 May 2010 16:24:10 +0200
On 2010-05-06 07:41:59 -0600, Eric Blake wrote:
> No, you're missing one other key point of POSIX:
> 
> http://www.opengroup.org/onlinepubs/9699919799/utilities/V3_chap01.html
> Section 1.4, OPTIONS:
> 
>     Default Behavior: When this section is listed as "None.", it means
> that the implementation need not support any options. Standard utilities
> that do not accept options, but that do accept operands, shall recognize
> "--" as a first argument to be discarded.

OK, an alternative way would be that an exception is added to POSIX,
just like for "echo".

>     The requirement for recognizing "--" is because conforming
> applications need a way to shield their operands from any arbitrary
> options that the implementation may provide as an extension. For
> example, if the standard utility foo is listed as taking no options, and
> the application needed to give it a pathname with a leading <hyphen>, it
> could safely do it as:
> 
>     foo -- -myfile
> 
>     and avoid any problems with -m used as an extension.

However, if extensions are allowed, this would mean that many scripts
would have to be fixed.

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / Arénaire project (LIP, ENS-Lyon)




Information forwarded to debian-bugs-dist@lists.debian.org, Michael Stone <mstone@debian.org>:
Bug#580492; Package coreutils. (Thu, 06 May 2010 14:33:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to Eric Blake <eblake@redhat.com>:
Extra info received and forwarded to list. Copy sent to Michael Stone <mstone@debian.org>. (Thu, 06 May 2010 14:33:03 GMT) Full text and rfc822 format available.

Message #75 received at 580492@bugs.debian.org (full text, mbox):

From: Eric Blake <eblake@redhat.com>
To: Vincent Lefevre <vincent@vinc17.net>, bug-coreutils@gnu.org, 580492@bugs.debian.org
Subject: Re: bug#6124: basename/dirname are not POSIX compliant on arg starting with a dash
Date: Thu, 06 May 2010 08:29:57 -0600
[Message part 1 (text/plain, inline)]
On 05/06/2010 08:24 AM, Vincent Lefevre wrote:
>>     Default Behavior: When this section is listed as "None.", it means
>> that the implementation need not support any options. Standard utilities
>> that do not accept options, but that do accept operands, shall recognize
>> "--" as a first argument to be discarded.
> 
> OK, an alternative way would be that an exception is added to POSIX,
> just like for "echo".

Please no.  echo has an exception precisely because it has historical
baggage, and that is what makes echo so pitiful that POSIX itself states
that printf(1) is more portable than echo(1).  Relatively newer
applications, like basename and dirname, that were first written in an
age when consistency was more important, should not be burdened with the
historical baggage of ancient echo(1).  And changing it now is too late;
just as you argue about the number of broken scripts that are not robust
because they failed to use --, you have to also consider the number of
correct scripts that have been written with the correct assumption that
basename and dirname accept --: it has been 9 years since POSIX 2001
first codified that behavior.

Besides, we would much prefer to keep 'basename --help' as a GNU
extension.  Not having 'POSIXLY_CORRECT=1 /bin/echo --help' give useful
help is an annoyance that we would rather avoid repeating.

> 
> However, if extensions are allowed, this would mean that many scripts
> would have to be fixed.

Yes, many broken scripts need to be fixed.  But that is the fault of
those broken scripts, not coreutils.

-- 
Eric Blake   eblake@redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

[signature.asc (application/pgp-signature, attachment)]

Information forwarded to debian-bugs-dist@lists.debian.org:
Bug#580492; Package coreutils. (Thu, 06 May 2010 14:42:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Michael Stone <mstone@debian.org>:
Extra info received and forwarded to list. (Thu, 06 May 2010 14:42:03 GMT) Full text and rfc822 format available.

Message #80 received at 580492@bugs.debian.org (full text, mbox):

From: Michael Stone <mstone@debian.org>
To: Vincent Lefevre <vincent@vinc17.net>, Eric Blake <eblake@redhat.com>, bug-coreutils@gnu.org, 580492@bugs.debian.org
Subject: Re: Bug#580492: bug#6124: basename/dirname are not POSIX compliant on arg starting with a dash
Date: Thu, 06 May 2010 10:39:13 -0400
On Thu, May 06, 2010 at 04:24:10PM +0200, you wrote:
>However, if extensions are allowed, this would mean that many scripts
>would have to be fixed.

Frankly, there are vast numbers of scripts which don't use -- at all, 
even for things like rm. I think you overstate both the amount of work 
and the likelihood that many scripts will bother.

Mike Stone




Information forwarded to debian-bugs-dist@lists.debian.org, Michael Stone <mstone@debian.org>:
Bug#580492; Package coreutils. (Thu, 06 May 2010 15:42:10 GMT) Full text and rfc822 format available.

Acknowledgement sent to Vincent Lefevre <vincent@vinc17.net>:
Extra info received and forwarded to list. Copy sent to Michael Stone <mstone@debian.org>. (Thu, 06 May 2010 15:42:10 GMT) Full text and rfc822 format available.

Message #85 received at 580492@bugs.debian.org (full text, mbox):

From: Vincent Lefevre <vincent@vinc17.net>
To: Eric Blake <eblake@redhat.com>
Cc: Pádraig Brady <P@draigBrady.com>, bug-coreutils@gnu.org, 580492@bugs.debian.org
Subject: Re: bug#6124: basename/dirname are not POSIX compliant on arg starting with a dash
Date: Thu, 6 May 2010 17:38:51 +0200
On 2010-05-06 08:02:04 -0600, Eric Blake wrote:
> On 05/06/2010 07:23 AM, Vincent Lefevre wrote:
> > According to
> > 
> >   grep 'basename --' /usr/bin/*
> >   grep 'basename \$' /usr/bin/*
> > 
> > on my Debian machine, almost all scripts use basename without "--".
> > The only exceptions are autoconf (but I'm not sure this counts, as
> > there's a test for "basename --" first,
> 
> Can you find an actual example of this?  I think you read it
> incorrectly, as really, autoconf first tests for 'basename -- /', but if
> you indeed found an instance of autoconf testing for 'basename --', that
> would be a bug in autoconf that needs to be reported to that list.

Sorry, I meant it was testing basename with "--" as the first
argument while in this case it is useless. So, I wondered whether
the goal of this test was to test whether this form was supported.

> >> Note solaris behaves like busybox and openbsd behaves like coreutils.
> > 
> > Perhaps they're copying coreutils without looking at what POSIX says.
> 
> Or, more likely, perhaps they are independently obeying what POSIX says,
> without reference to either coreutils or busybox.

So, I think I should reassign the bug to busybox?

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / Arénaire project (LIP, ENS-Lyon)




Information forwarded to debian-bugs-dist@lists.debian.org, Michael Stone <mstone@debian.org>:
Bug#580492; Package coreutils. (Thu, 06 May 2010 16:57:05 GMT) Full text and rfc822 format available.

Acknowledgement sent to Eric Blake <eblake@redhat.com>:
Extra info received and forwarded to list. Copy sent to Michael Stone <mstone@debian.org>. (Thu, 06 May 2010 16:57:05 GMT) Full text and rfc822 format available.

Message #90 received at 580492@bugs.debian.org (full text, mbox):

From: Eric Blake <eblake@redhat.com>
To: Vincent Lefevre <vincent@vinc17.net>, Pádraig Brady <P@draigBrady.com>, bug-coreutils@gnu.org, 580492@bugs.debian.org
Subject: Re: bug#6124: basename/dirname are not POSIX compliant on arg starting with a dash
Date: Thu, 06 May 2010 10:52:55 -0600
[Message part 1 (text/plain, inline)]
On 05/06/2010 09:38 AM, Vincent Lefevre wrote:
>>> there's a test for "basename --" first,
>>
>> Can you find an actual example of this?  I think you read it
>> incorrectly, as really, autoconf first tests for 'basename -- /', but if
>> you indeed found an instance of autoconf testing for 'basename --', that
>> would be a bug in autoconf that needs to be reported to that list.
> 
> Sorry, I meant it was testing basename with "--" as the first
> argument while in this case it is useless. So, I wondered whether
> the goal of this test was to test whether this form was supported.

Yes, the goal of that autoconf test is to determine whether basename(1)
supports leading --, as required by POSIX.

>> Or, more likely, perhaps they are independently obeying what POSIX says,
>> without reference to either coreutils or busybox.
> 
> So, I think I should reassign the bug to busybox?

Yes.

-- 
Eric Blake   eblake@redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

[signature.asc (application/pgp-signature, attachment)]

Information forwarded to debian-bugs-dist@lists.debian.org, Michael Stone <mstone@debian.org>:
Bug#580492; Package coreutils. (Thu, 06 May 2010 23:00:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to Vincent Lefevre <vincent@vinc17.net>:
Extra info received and forwarded to list. Copy sent to Michael Stone <mstone@debian.org>. (Thu, 06 May 2010 23:00:03 GMT) Full text and rfc822 format available.

Message #95 received at 580492@bugs.debian.org (full text, mbox):

From: Vincent Lefevre <vincent@vinc17.net>
To: 580492@bugs.debian.org
Subject: Re: basename/dirname are not POSIX compliant on arg starting with a dash
Date: Fri, 7 May 2010 00:57:24 +0200
reassign 580492 busybox
retitle 580492 busybox basename/dirname should discard the first arg when it is --
severity 580492 important
thanks

The explanations are in the earlier discussion.

The effects of this bug:
  * It breaks POSIX-compliant scripts that use basename/dirname with
    "--" for correct behavior (and possibly security reasons).
  * It prevents one from fixing scripts that do not use "--" if
    compatibility with BusyBox is important.

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / Arénaire project (LIP, ENS-Lyon)




Bug reassigned from package 'coreutils' to 'busybox'. Request was from Vincent Lefevre <vincent@vinc17.net> to control@bugs.debian.org. (Thu, 06 May 2010 23:00:04 GMT) Full text and rfc822 format available.

Bug No longer marked as found in versions coreutils/8.5-1. Request was from Vincent Lefevre <vincent@vinc17.net> to control@bugs.debian.org. (Thu, 06 May 2010 23:00:05 GMT) Full text and rfc822 format available.

Changed Bug title to 'busybox basename/dirname should discard the first arg when it is --' from 'coreutils: basename/dirname are not POSIX compliant on arg starting with a dash' Request was from Vincent Lefevre <vincent@vinc17.net> to control@bugs.debian.org. (Thu, 06 May 2010 23:00:06 GMT) Full text and rfc822 format available.

Severity set to 'important' from 'normal' Request was from Vincent Lefevre <vincent@vinc17.net> to control@bugs.debian.org. (Thu, 06 May 2010 23:00:07 GMT) Full text and rfc822 format available.

Added tag(s) patch. Request was from Michael Tokarev <mjt@tls.msk.ru> to control@bugs.debian.org. (Wed, 09 Mar 2011 21:42:03 GMT) Full text and rfc822 format available.

Added tag(s) pending. Request was from Michael Tokarev <mjt@tls.msk.ru> to control@bugs.debian.org. (Fri, 18 Mar 2011 12:03:08 GMT) Full text and rfc822 format available.

Reply sent to Michael Tokarev <mjt@tls.msk.ru>:
You have taken responsibility. (Fri, 18 Mar 2011 12:51:09 GMT) Full text and rfc822 format available.

Notification sent to Vincent Lefevre <vincent@vinc17.net>:
Bug acknowledged by developer. (Fri, 18 Mar 2011 12:51:09 GMT) Full text and rfc822 format available.

Message #112 received at 580492-close@bugs.debian.org (full text, mbox):

From: Michael Tokarev <mjt@tls.msk.ru>
To: 580492-close@bugs.debian.org
Subject: Bug#580492: fixed in busybox 1:1.18.4-1
Date: Fri, 18 Mar 2011 12:47:15 +0000
Source: busybox
Source-Version: 1:1.18.4-1

We believe that the bug you reported is fixed in the latest version of
busybox, which is due to be installed in the Debian FTP archive:

busybox-static_1.18.4-1_amd64.deb
  to main/b/busybox/busybox-static_1.18.4-1_amd64.deb
busybox-syslogd_1.18.4-1_all.deb
  to main/b/busybox/busybox-syslogd_1.18.4-1_all.deb
busybox-udeb_1.18.4-1_amd64.udeb
  to main/b/busybox/busybox-udeb_1.18.4-1_amd64.udeb
busybox_1.18.4-1.debian.tar.gz
  to main/b/busybox/busybox_1.18.4-1.debian.tar.gz
busybox_1.18.4-1.dsc
  to main/b/busybox/busybox_1.18.4-1.dsc
busybox_1.18.4-1_amd64.deb
  to main/b/busybox/busybox_1.18.4-1_amd64.deb
busybox_1.18.4.orig.tar.bz2
  to main/b/busybox/busybox_1.18.4.orig.tar.bz2
udhcpc_1.18.4-1_all.deb
  to main/b/busybox/udhcpc_1.18.4-1_all.deb
udhcpd_1.18.4-1_all.deb
  to main/b/busybox/udhcpd_1.18.4-1_all.deb



A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to 580492@bugs.debian.org,
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Michael Tokarev <mjt@tls.msk.ru> (supplier of updated busybox package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing ftpmaster@debian.org)


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Format: 1.8
Date: Thu, 17 Mar 2011 16:18:35 +0300
Source: busybox
Binary: busybox busybox-static busybox-udeb busybox-syslogd udhcpc udhcpd
Architecture: source all amd64
Version: 1:1.18.4-1
Distribution: unstable
Urgency: low
Maintainer: Debian Install System Team <debian-boot@lists.debian.org>
Changed-By: Michael Tokarev <mjt@tls.msk.ru>
Description: 
 busybox    - Tiny utilities for small and embedded systems
 busybox-static - Standalone rescue shell with tons of builtin utilities
 busybox-syslogd - Provides syslogd and klogd using busybox
 busybox-udeb - Tiny utilities for the debian-installer (udeb)
 udhcpc     - Provides the busybox DHCP client implementation
 udhcpd     - Provides the busybox DHCP server implementation
Closes: 310440 580492 615926 618644
Changes: 
 busybox (1:1.18.4-1) unstable; urgency=low
 .
   * new upstream bugfix release (1.18.4)
   * refreshed debian/patches/u-mount-FreeBSD-support.patch
     (fix build failure on kfreebsd) (Closes: #618644)
   * refreshed applets-fallback.patch (compensate for offsets)
   * added debian/udeb-sizes to track various options of udeb build
   * added dirname-basename-skip-doubledash.diff (Closes: #580492)
   * config:
    - enable sha1sum & sha512sum in udeb (Closes: #615926)
    - enable mktemp in udeb (Closes: #310440)
Checksums-Sha1: 
 40b37304a9c4cc2d7f1f6c053ab24b2e2d45e296 1890 busybox_1.18.4-1.dsc
 d285855e5770b0fb7caf477dd41ce0863657b975 2130598 busybox_1.18.4.orig.tar.bz2
 288761f0803a35938f89dedf6db5fcc176ef95b4 42350 busybox_1.18.4-1.debian.tar.gz
 d8c35e233e18a310009cb4bc699c2cdffc2c309d 15050 busybox-syslogd_1.18.4-1_all.deb
 c29c89048b29ea15d4f14bade8bb16e75895f71a 12750 udhcpc_1.18.4-1_all.deb
 e20b1a309bd4b592530202bced7c605c43e5268c 16024 udhcpd_1.18.4-1_all.deb
 14f569bd5bfc967bc287da9ec9918cb6a0570d48 347494 busybox_1.18.4-1_amd64.deb
 e8a8caa10b8e26ff02aeef5fd9251d33a168c400 822458 busybox-static_1.18.4-1_amd64.deb
 bd0996fbdbc0664b685ea636b464bdddce48c84a 169292 busybox-udeb_1.18.4-1_amd64.udeb
Checksums-Sha256: 
 1b0114bb9db1b1f929fd87a1f717fc33f824e8cb05605e857145c1b800af2bf0 1890 busybox_1.18.4-1.dsc
 4d24d37bd6f1bd153e8cf9a984ec2f32f18464f73ca535e2cc2e8be9694097fa 2130598 busybox_1.18.4.orig.tar.bz2
 1c75a50881c6cce63f1999f972f519124cc87764c09beac1cfdd7f9fc6dfd280 42350 busybox_1.18.4-1.debian.tar.gz
 651758a98350bc0b5e73b7edc396c92ae16fb3102a478e5ef31662f35f8d263f 15050 busybox-syslogd_1.18.4-1_all.deb
 3fed8177d07f6f831e87fb40c98541100dd2f23f9557ffdebcc75b22fe59947f 12750 udhcpc_1.18.4-1_all.deb
 4d176a648a15a761cdefe8a650abcb8980bd7cee738a9ae256977772db37312b 16024 udhcpd_1.18.4-1_all.deb
 e0507d77ef0f9c17434a1c2a695dd8efecea36d36c2e6766e7ce0ef5bfaef4b1 347494 busybox_1.18.4-1_amd64.deb
 f4332bb52392801c01227399addcb1a84b8722e0c9254a95a7de69294f06d72a 822458 busybox-static_1.18.4-1_amd64.deb
 1812e6523f047d871f1ff83354ed361d917b2a36b057c3111d55d27a2192566f 169292 busybox-udeb_1.18.4-1_amd64.udeb
Files: 
 37888d137c538f508143c2ce407b5b22 1890 utils optional busybox_1.18.4-1.dsc
 b03c5b46ced732679e525a920a1a62f5 2130598 utils optional busybox_1.18.4.orig.tar.bz2
 e67f35cc2bcb304b3a74350ea619f13a 42350 utils optional busybox_1.18.4-1.debian.tar.gz
 28168f1bdbdbf19d5d60c2ae42528926 15050 utils optional busybox-syslogd_1.18.4-1_all.deb
 cf438891c095e34cc6378304046140a9 12750 net optional udhcpc_1.18.4-1_all.deb
 0108605dfdd72cb034eeca1a92a97391 16024 net optional udhcpd_1.18.4-1_all.deb
 b2e65b14a0846168d541bde8f051ac8f 347494 utils optional busybox_1.18.4-1_amd64.deb
 4a938791e0d9e79b3bf26cc6a2ef6d40 822458 shells extra busybox-static_1.18.4-1_amd64.deb
 416e50e3af32d78d3369861ba401518c 169292 debian-installer extra busybox-udeb_1.18.4-1_amd64.udeb
Package-Type: udeb

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)

iQIcBAEBCAAGBQJNg1MNAAoJEOtw/vPN/G5P2kkQAL7Teoat1Ylimg0Hjsd4ussb
PWCLCnMHWoPP5l1w9BD1D9YiK0fx3cEUbJ4b3noeRPR3vZnqPjS1OIr8m4QCfuwh
FH/X6RkYIy/KT9j8Df8HYvDqkUX5X4x3o8lsSH4hTC0J6F7CEpryes9g0v6aU5fB
UYSgzzIkpvfhNwlhFyF79IG0F/j0pNIF4AECZYQfvSpwfO2zCGRi+qSwm/uIv2+F
LJ4fEUjuWTWXrROPgw0+O9HSru532dzlNOPvcO4QAvtjJwn5VAL0WuNz4FAM4MKI
QznOsIAvNHPvH2jDiFDVUF8fUvVG52bKbpJplkRc6hdoCqOKZzGVyq6D/emaDuPw
pdAuc1EptiXe7Je+Bko04GyNEi2qxkC6Fy/h9Ser/oHFNOnnhLuBFsDiTSjrmicW
M+u23DjC6y4zZV/+ENCJhnjk8tPiRrRaHr7ihmI2D+rEaLbajIYUOIjm8kh6AnM4
Q/bwg1Hd71yyl192AcDVu29vj7iRsvS4X+NPjs/zjiux6M4ZoZ+RtK4I5i61awQe
uCbAyx4nVDc6Ck9efXItNvxtYlRLc/eG8s/JTuQOAQ5rQsOD0REKV8M1XF6hw1u4
ZZiVH1PStD061ThKa9qkMm+akSTCP7Lg+L72nD4sxiVW80JlcTytOOpMVedL86vR
BPKz+Fsn9DvDX4XKEnVE
=qDIl
-----END PGP SIGNATURE-----





Bug archived. Request was from Debbugs Internal Request <owner@bugs.debian.org> to internal_control@bugs.debian.org. (Wed, 29 Jun 2011 07:37:59 GMT) Full text and rfc822 format available.

Send a report that this bug log contains spam.


Debian bug tracking system administrator <owner@bugs.debian.org>. Last modified: Fri Apr 25 02:13:57 2014; Machine Name: buxtehude.debian.org

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