On older versions of FreeBSD/NetBSD: $ dirname //usr//bin //usr $ uname -a FreeBSD fbsd10 10.3-STABLE FreeBSD 10.3-STABLE #52 r302447M: Fri Jul 8 12:44:14 PDT 2016 ngie@fbsd10:/usr/obj/usr/src/sys/GENERIC amd64 On newer versions (post the recent basename/dirname changes): $ dirname //usr//bin /usr $ uname -a FreeBSD fbsd11 12.0-CURRENT FreeBSD 12.0-CURRENT #6 r304831: Thu Aug 25 23:47:28 PDT 2016 ngie@fbsd11:/usr/obj/usr/src/svn/sys/GENERIC amd64
Yes, that's expected. The new dirname() implementation is guaranteed to generate a normalized pathname string. Redundant slashes and dot components are removed. Is this causing any problems?
Oh, wow. This is interesting. It looks like POSIX puts stronger requirements on the output of dirname(1) than on dirname(3). The example that you gave *must* return a path with the exact number of leading slashes left intact. Let me think of a way to solve this cleanly.
A commit references this bug: Author: ngie Date: Mon Aug 29 17:50:36 UTC 2016 New revision: 305007 URL: https://svnweb.freebsd.org/changeset/base/305007 Log: Expect :basic to fail due to recent output changes in dirname(3) The dirname output change bug is actively being worked on, and this commit will need to be reverted once it's fixed. MFC after: never PR: 212193 Sponsored by: EMC / Isilon Storage Division Changes: head/contrib/netbsd-tests/usr.bin/dirname/t_dirname.sh
Ideally the Austin Group can be convinced that it's silly to specify different behaviour for dirname(1) and dirname(3).
Bug report at the Austin Group: http://austingroupbugs.net/view.php?id=1073
A commit references this bug: Author: ngie Date: Mon Aug 29 22:34:31 UTC 2016 New revision: 305030 URL: https://svnweb.freebsd.org/changeset/base/305030 Log: Fix typo atf_tc_expect_fail should have been atf_expect_fail per atf-sh-api(3) PR: 212193 Pointyhat to: ngie Sponsored by: EMC / Isilon Storage Division Changes: projects/netbsd-tests-update-12/contrib/netbsd-tests/usr.bin/dirname/t_dirname.sh
A commit references this bug: Author: ngie Date: Mon Aug 29 22:38:18 UTC 2016 New revision: 305031 URL: https://svnweb.freebsd.org/changeset/base/305031 Log: Fix typo atf_tc_expect_fail should have been atf_expect_fail per atf-sh-api(3) PR: 212193 Pointyhat to: ngie Sponsored by: EMC / Isilon Storage Division Changes: _U head/ head/contrib/netbsd-tests/usr.bin/dirname/t_dirname.sh
A commit references this bug: Author: ed Date: Sun Sep 18 20:47:55 UTC 2016 New revision: 305952 URL: https://svnweb.freebsd.org/changeset/base/305952 Log: Replace dirname(3) by a copy that complies to POSIX. It turns out that the path normalization that our brand new copy of dirname(3) does is actually not allowed by the draft version of the upcoming version of POSIX. It has to behave identically to the dirname(1) utility. This change replaces our new dirname(3) implementation by yet another version that doesn't implement the path normalization logic; it merely looks for the end of the directory name and overwrites that with a null byte. More details: See note #3370 at http://austingroupbugs.net/view.php?id=1073 PR: 212193 Reviewed by: emaste, jilles Differential Revision: https://reviews.freebsd.org/D7790 Changes: head/lib/libc/gen/dirname.3 head/lib/libc/gen/dirname.c
A commit references this bug: Author: ngie Date: Mon Sep 19 06:39:08 UTC 2016 New revision: 305958 URL: https://svnweb.freebsd.org/changeset/base/305958 Log: Remove expected failure for :basic (effectively reverting r305007, r305031) This no longer fails as of r305952 PR: 212193 Sponsored by: Dell EMC Isilon Changes: head/contrib/netbsd-tests/usr.bin/dirname/t_dirname.sh
Closing bug (now fixed). Thanks ed!