From: Christian Weisgerber Subject: Fix rmdir -p /foo/bar To: tech@openbsd.org Date: Sun, 11 May 2025 03:30:02 +0200 # rmdir -p /.ssh/agent rmdir: : No such file or directory FreeBSD fixed this twenty years ago. OK? ----------------------------------------------- commit 26cd495101f3980b146e32f8974ad31b104ea1c4 (llvm19) from: Christian Weisgerber date: Sat May 10 21:38:01 2025 UTC Do not emit a spurious warning when "directory" argument to "rmdir -p" is absolute, with one or more leading slashes. from FreeBSD diff 15e4ef841b85919e980eddb4997fc694f6003f24 26cd495101f3980b146e32f8974ad31b104ea1c4 commit - 15e4ef841b85919e980eddb4997fc694f6003f24 commit + 26cd495101f3980b146e32f8974ad31b104ea1c4 blob - 0197254749acbef1496562627053a7b80fdfd5ec blob + cf75833643ff15eb26f76d98f72877275db1ba92 --- bin/rmdir/rmdir.c +++ bin/rmdir/rmdir.c @@ -92,9 +92,11 @@ rm_path(char *path) while ((p = strrchr(path, '/')) != NULL) { /* Delete trailing slashes. */ - while (--p > path && *p == '/') + while (--p >= path && *p == '/') continue; *++p = '\0'; + if (p == path) + break; if (rmdir(path) == -1) { warn("%s", path); -- Christian "naddy" Weisgerber naddy@mips.inka.de