by bariumbitmap · 2mo ago · 0 comments
> 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.
from the lstat man page:
The lstat() function is identical to stat() except when the named file is
a symbolic link, in which case lstat() returns information about the link
itself, not the file the link references.
symbolic link example: $ tree test1
test1
|-- file.txt
`-- link.txt -> ../link.txt
0 directory, 2 files
$ cp -r test1 test2
$ tree test2
test2
|-- file.txt
`-- link.txt
0 directory, 2 files
$ cp -R test1 test3
$ tree test3
test3
|-- file.txt
`-- link.txt -> ../link.txt
0 directory, 2 files
For posterity, -R with added -L $ cp -RL test1 test4
$ tree test4/
test4/
|-- file.txt
`-- link.txt
0 directory, 2 filesThe snippet of code makes it very clear what the difference is, no?
flag_copy_as_regular = 1 VS flag_copy_as_regular = 0, where regular would be a "regular" and not "special" file.
My first thought was 'regular expression'. I've also never heard of the classification of a 'special' file in *nix land either (at least as utility flags go).