Bug 3463 - basename and dirname should skip first `--' argument
Summary: basename and dirname should skip first `--' argument
Status: RESOLVED FIXED
Alias: None
Product: Busybox
Classification: Unclassified
Component: Standard Compliance (show other bugs)
Version: 1.18.x
Hardware: All Linux
: P5 minor
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-03-09 20:59 UTC by Michael Tokarev
Modified: 2011-04-11 02:00 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:


Attachments
patch that fixes the issue (755 bytes, text/x-c)
2011-03-09 20:59 UTC, Michael Tokarev
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Tokarev 2011-03-09 20:59:11 UTC
Created attachment 3139 [details]
patch that fixes the issue

According to POSIX, both basename and dirname accepts no options, ie, their "OPTIONS" sections in POSIX tells "None.": http://www.opengroup.org/onlinepubs/9699919799/utilities/basename.html and http://www.opengroup.org/onlinepubs/9699919799/utilities/dirname.html .

There's a chapter in the standard that describes what does this mean: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap01.html

See 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.

Here's another reference to the topic: http://austingroupbugs.net/view.php?id=192#c324 .

And finally a debian bugreport about this all: http://bugs.debian.org/580492 .

Attached is a trivial patch that makes both basename and dirname skip "--" if given as a first argument.

Thanks!
Comment 1 Denys Vlasenko 2011-04-11 02:00:48 UTC
It makes more sense to put fix in single_argv() function.

Applied, thanks!