Subject: Re: bug#6175: dirname manpage and info page partially wrong/misleading

From: Eric Blake <[email-masked]>
Date: Mon, 17 May 2010 09:36:09 -0600

On 05/17/2010 09:17 AM, Filipus Klutiero wrote:
>> Strip the last component and resulting trailing slashes; if the file
>> name contains only one component, print '.'.
>>
>> But I welcome your ideas for a coherent sentence.
>>    
> That sounds more correct and comprehensible. I don't know how many
> corner cases there are and if they can all be covered in the help, but
> there's also the no component case:
> $ dirname ''
> prints ".".

Yes, that's a corner case not covered by the above sentence, which we
could fix with "if the file name contains less than two components,
print '.'".

> $ dirname /
> prints "/".

I tend to classify the all-slash corner case as being one component, not
zero components.  You can view it as the root directory being  contained
in (well, reachable from) the root directory, as evidenced by '/../'
resolving to '/'.  But that doesn't work as well with the '<2
components' wording above, so I'm feeling more comfortable with leaving
the corner-cases undocumented in the terse --help output, by using your
view that '/' has no components rather than 1, and anyone worried about
the two corner cases of '' and '/' can read the info page.

-- 
Eric Blake   [email-masked]    +1-801-349-2682
Libvirt virtualization library http://libvirt.org