GNU bug report logs - #6175
dirname manpage and info page partially wrong/misleading

Previous Next

Package: coreutils;

Reported by: Filipus Klutiero <chealer <at> gmail.com>

Date: Tue, 11 May 2010 21:30:02 UTC

Severity: normal

Done: Jim Meyering <jim <at> meyering.net>

Bug is archived. No further changes may be made.

Full log


Message #17 received at 6175 <at> debbugs.gnu.org (full text, mbox):

From: Filipus Klutiero <chealer <at> gmail.com>
To: Eric Blake <eblake <at> redhat.com>
Cc: 6175 <at> debbugs.gnu.org
Subject: Re: bug#6175: dirname manpage and info page partially wrong/misleading
Date: Mon, 17 May 2010 15:48:22 -0400
On 2010-05-17 11:36, Eric Blake wrote:
> 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 '/'.
Hum, interesting, never thought about "/../". I believe all-slash can't 
be considered as being one component. According to POSIX, a component 
needs at least one character.
>    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.
>    
Using If-s is a good idea. I would agree with leaving the no components 
case to the documentation proper. Here is a simple even though 
incomplete description based on yours. It is exact *AFAIK*. I'm using 
"pathname" instead of "file name", since file name doesn't fit the Base 
Specifications definition - but I don't know if coreutils/GNU is 
willingly using its own terminology.

If the pathname contains several components, strip the last component 
and resulting trailing slashes; if the pathname contains only one 
component, print '/' if the pathname starts with a slash, '.' otherwise.




This bug report was last modified 14 years and 42 days ago.

Previous Next


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