[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#6124: basename/dirname are not POSIX compliant on arg starting with
bug#6124: basename/dirname are not POSIX compliant on arg starting with a dash
Thu, 06 May 2010 13:50:27 +0100
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:126.96.36.199) Gecko/20100227 Thunderbird/3.0.3
On 06/05/10 12:15, Vincent Lefevre wrote:
> I've reported the following bug in the Debian BTS:
> 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
> [*] http://www.opengroup.org/onlinepubs/9699919799/utilities/basename.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.
bug#6123: basename/dirname are not POSIX compliant on arg starting with a dash, Vincent Lefevre, 2010/05/06
bug#6124: basename/dirname are not POSIX compliant on arg starting with a dash, Eric Blake, 2010/05/06