From fbc1bbbec18d062e1fffc201e6bfee0cabbd8a37 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 16 Nov 2026 19:26:18 -0800 Subject: [PATCH] doc: document "rm -r s/" on symlink s (bug#82259) --- doc/coreutils.texi | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/doc/coreutils.texi b/doc/coreutils.texi index 2905c1d75..98b25fc50 100644 --- a/doc/coreutils.texi +++ b/doc/coreutils.texi @@ -10019,13 +10019,12 @@ is a terminal, and the @option{-f} or @option{--force} option is not given, own the file, or have write permission on its directory.) If the response is not affirmative, the file is skipped. -Avoid specifying a source name with a trailing slash, -when it might be a symlink to a directory. -Otherwise, @command{mv} may do something very surprising, since -its behavior depends on the underlying rename system call. -On a system with a modern Linux-based kernel, it fails with -@code{errno=ENOTDIR}@. -However, on other systems (at least FreeBSD 6.1 and Solaris 10) it silently +Avoid specifying a source name with a trailing slash +when the unslashed name might be that of a symbolic link to a directory. +Otherwise, @command{mv} may do something surprising, +since its behavior depends on the platform. +On a Linux-based kernels @command{mv} fails with a diagnostic; +on BSDish kernels it silently renames not the symlink but rather the directory referenced by the symlink. @xref{Trailing slashes}. @@ -10246,6 +10245,16 @@ remove all the files on your computer. @cindex directories, removing (recursively) Remove the listed directories and their contents recursively. +When using this option, avoid specifying a file name with a trailing slash +when the unslashed name might be that of a symbolic link to a directory. +Otherwise, @command{rm} may do something surprising +after it removes all files under the directory, +since the behavior depends on the platform. +On a Linux-based kernel, @command{rm} fails with a diagnostic; +on BSDish kernels it silently removes not the symlink but rather the +directory referenced by the symlink. +@xref{Trailing slashes}. + @optItem{rm,-v,} @optItemx{rm,--verbose,} Print the name of each file before removing it. @@ -11155,6 +11164,15 @@ rmdir [@var{option}]@dots{} @var{directory}@dots{} If any @var{directory} argument does not refer to an existing empty directory, it is an error. +Avoid specifying a file name with a trailing slash +when the unslashed name might be that of a symbolic link to a directory. +Otherwise, @command{rmdir} may do something surprising, +since the behavior depends on the platform. +On a Linux-based kernel, @command{rmdir} fails with a diagnostic; +on BSDish kernels it silently removes not the symlink but rather the +directory referenced by the symlink. +@xref{Trailing slashes}. + The program accepts the following options. Also see @ref{Common options}. @table @samp