更新时间:2022-01-10 21:57:12
Mac使用的BSD cp
与大多数Linux发行版的GNU cp
之间存在一些细微的差异.
There a few subtle differences between the BSD cp
that Mac uses and the GNU cp
of most linux distributions.
在Linux机器上考虑以下man cp
片段:
Consider the following snippet of man cp
from a linux box:
-d same as --no-dereference --preserve=links
-P, --no-dereference
never follow symbolic links in SOURCE
--preserve[=ATTR_LIST]
preserve the specified attributes (default: mode,ownership,timestamps), if possible additional attributes: context,
links, xattr, all
因此,基本上,它试图做的是复制以下路径,如果它们是链接,则仅复制链接,而不是底层文件."
So basically what it's trying to do is "copy the following paths, and if they're links, just copy the link, not the underlying file."
p
选项在Mac下存在,等效于linux行为.但是,没有d
选项.
The p
option exists under Mac and is equivalent to the linux behavior. The d
option, however, is absent.
我试图找到一种方法来模仿Mac cp
上的复制链接,而不是目标"的行为,据我所知,没有令人愉快的方法.
I've tried to figure out a way to mimic the behavior of "copy links, not targets" with the Mac cp
, and as far as I can tell, there's no pleasant way to do it.
幸运的是,这里的工作很艰巨.在Mac上的man cp
中:
There is, fortunately, a gross work around. From man cp
under Mac:
除非设置-R标志,否则始终遵循符号链接,在这种情况下,默认情况下不遵循符号链接.
Symbolic links are always followed unless the -R flag is set, in which case symbolic links are not followed, by default.
换句话说,由于我们知道我们只是在复制文件,因此您可以简单地将d
标志替换为R
标志.行为在技术上有所不同(非常有所不同),但在此特定情况下无关紧要.您需要找到Makefile中使用的cp
标志(希望在文件顶部的CP
变量中)并只需对其进行更改.
In other words, since we know we're only copying files, you can simply replace the d
flag with the R
flag. The behavior is technically different (very different), but it won't matter in this specific case. You'll need to find the cp
flags used in the Makefile (hopefully in a CP
variable at the top of the file) and simply change them.
如果确定cp
是Makefile中要执行的最后一件事,则还可以复制并粘贴它,而不用更改Makefile.
If you're sure the cp
is the last thing to be executed in the Makefile, you could also just copy and paste it instead of changing the Makefile.