bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [dirname] fix documentation when using on a full directory path


From: Chris F.A. Johnson
Subject: Re: [dirname] fix documentation when using on a full directory path
Date: Fri, 12 Feb 2010 13:01:02 -0500 (EST)
User-agent: Alpine 2.00 (LMD 1167 2008-08-23)

On Fri, 12 Feb 2010, Emmanuel Lacour wrote:

> coreutils 6.10-6 (debian lenny x86 32bit)
> 
> when we use "dirname /full/directory/path/" we get "/full/directory/",
> but documentation say:
> 
> dirname - strip non-directory suffix from file name
>                 ^^^^^^^^^^^^^^^^^^^^
> 
> so either there is a need to update the documentation to say it is
> removing the last component (wether it's a dir or a file) or fix dirname
> so it returns "/full/directory/path/".

    It's not the way I would have done it (not that I ever use an
    external command for something that can be done in the shell
    itself), but the POSIX spec for dirname says that any trailing
    slashes are removed before anything else is done:

    1. If string is //, skip steps 2 to 5.
    2. If string consists entirely of <slash> characters, string shall be
       set to a single <slash> character. In this case, skip steps 3 to 8.
*** 3. If there are any trailing <slash> characters in string, they shall
       be removed.
    4. If there are no <slash> characters remaining in string, string
       shall be set to a single <period> character. In this case, skip
       steps 5 to 8.
    5. If there are any trailing non- <slash> characters in string, they
       shall be removed.
    6. If the remaining string is //, it is implementation-defined whether
       steps 7 and 8 are skipped or processed.
    7. If there are any trailing <slash> characters in string, they shall
       be removed.
    8. If the remaining string is empty, string shall be set to a single
       <slash> character.


-- 
   Chris F.A. Johnson                          <http://cfajohnson.com>
   ===================================================================
   Author:
   Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
   Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]