需求卡片 #350 · 相关性 中 · 新发现

cp 命令 -r 与 -R 选项的混淆与文档缺失

更新于 2026/10/8 22:05:33

问题概述

用户对 cp 命令的 -r 与 -R 选项意义不明确,且文档缺失导致误用,尤其在复制特殊文件时会产生错误或挂起。多位评论者指出历史差异和官方手册的缺失,呼吁更清晰的说明。

痛点标签

待验证问题

证据

原话 · @Anonymous
This blog post is odd because it keeps on hinting about a difference between `-r' and `-R' and links to the source code but never actually says what it is.
原话 · @Anonymous
Historic versions of the cp utility had an -r option. This implementation supports that option; however, its use is strongly discouraged, as it does not correctly copy special files, symbolic links or FIFOs.
原话 · @Anonymous
For those that don't know what 'copy as regular file' means, it means the copy command opens any file as though it was a regular file. If you have a FIFO queue sitting around it will read the content of the FIFO queue - if nothing writes to it, the command will hang. If you do cp -r /dev/zero foo, it will write zeroes into foo until the disk is full. -R otoh will copy a fifo queue as a fifo queue.

免责声明:本卡片由 AI 从社区讨论中提炼,属于「痛点证据」,是需求分析与验证的起点,不等同于「已验证的市场需求」。AI 存在分析局限,关键决策前请打开上方原始讨论人工复核。