[bug #56855] find -printf %h gives an empty string for the root directory '/'

Eric Blake <[email protected]>
Newsgroups gmane.comp.gnu.findutils.bugs
Message-ID <[email protected]>
Follow-up Comment #3, bug #56855 (project findutils):

POSIX is clear in
https://pubs.opengroup.org/onlinepubs/9699919799/functions/dirname.html that
the dirname(3) function returns a non-empty string for input of "/".  However,
POSIX is also clear that the string composed by
'dirname(str)+"/"+basename(str)' need NOT refer to the same file as 'str';
case in point: when str is "//", POSIX says you could end up with any of
"///", "////", or "/////" depending on choices made in basename and dirname,
but all of those results are equivalent to to "/" while POSIX is explicit that
"//" may be distinct from "/".

Similar arguments can be made about the behavior of the basename(1) utility.

However, since -printf is not defined by POSIX, there is no requirement that
%h be defined by the POSIX functionality of basename(3) (the function), nor of
basename(1) (the utility).  However, if we intend to return the empty string,
it IS a bug if our documentation is not explicit that we intentionally differ
in behavior from the POSIX functions, and give examples why we think that is
the right thing to do.


    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?56855>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.