Bug 3463

Summary: basename and dirname should skip first `--' argument
Product: Busybox Reporter: Michael Tokarev <mjt+busybox>
Component: Standard ComplianceAssignee: unassigned
Status: RESOLVED FIXED    
Severity: minor CC: busybox-cvs
Priority: P5    
Version: 1.18.x   
Target Milestone: ---   
Hardware: All   
OS: Linux   
Host: Target:
Build:
Attachments: patch that fixes the issue

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!