hn.today

cp: -r or -R?

movq.de5 points0 comments
Screenshot of cp: -r or -R?

This explains whether cp -r and cp -R differ. Early GNU coreutils did treat them differently: a 1992 cp.c commit set '-r' to flag_recursive and flag_copy_as_regular=1, while '-R' set flag_copy_as_regular=0, so behavior diverged. That distinction disappeared around 2002 when the options were merged in GNU coreutils, and modern GNU manuals list them as synonyms: "-R, -r recursive copy directories recursively." In short, current GNU users can expect no difference, and running decades-old coreutils is the only way to observe the original split.

Other Unix-like systems still matter: OpenBSD 7.9 and NetBSD 11 document only -R and discourage -r, and their implementations still maintain separate rflag and Rflag code paths, so behavior may differ there. POSIX has moved to prefer -R, noting -r as historical BSD practice and adding -R for consistency across recursive options in utilities (chown, etc.). Practical takeaway: use -R for cross-platform consistency and compatibility with standards and other tools; -r is legacy and may behave differently on non-GNU systems.

Read on movq.de0 comments on Hacker News

Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.

More in Programming

Zig v0.17.0

Zig v0.17.0

Zig 0.17.0 introduces a reworked build system, including a new Build Server Protocol and enhanced ELF Linker for better incremental compilation on x86_64-linux. The release also features numerous language, standard library, and package management improvements contributed by over 200 developers. (ziglang.org)

Hardly Promethean

Hardly Promethean

Decreasing costs of native app development and performance optimization shift the software bottleneck from coding to deployment and maintenance. Experts argue that while technology enables faster coding, managing and shipping updates remains a significant challenge. (jardo.dev)

The daily digest

Today's best Hacker News stories, summarized and screenshotted, one email a day.