在 Windows 中的 Msys2 或 Git Bash 中复制 exe 文件时出现 cp 问题

问题描述 投票:0回答:1

我在 Git Bash 中遇到了一个关于

cp
的奇怪问题,对于 Msys2 shell 也是如此。当复制
exe
文件(例如,
some-file.exe
)以及同名但无扩展名的文件(例如,
some-file
)时,它只会复制
some-file
,但名称为
some-file.exe
。以下是重现步骤。

mkdir a-new-tmp-folder
cd a-new-tmp-folder
mkdir tmp
echo "file" >file
echo "file.exe" >file.exe
cp -t tmp file.exe file
ls tmp              # only `file.exe' there
cat tmp/file.exe    # shows `file' instead of expected `file.exe'

但是,如果交换 cp (

cp -t tmp file file.exe
) 的最后 2 个参数,就不会有任何问题。有谁可以帮忙解释一下吗?

windows git-bash msys2 git-for-windows
1个回答
0
投票

Msys2 待办事项列表中所述,这是一个已知问题,因为 运行时还通过在各种 FS 调用上查找

.exe
来模拟无扩展的可执行文件

此问题目前似乎没有解决方案或解决方法。

修复 pacman 错误。
bin/foo
bin/foo.exe

之间的冲突

运行时还通过在各种 FS 调用上查找

.exe
来模拟无扩展的可执行文件。 (这样的黑客攻击还有很多,例如符号链接模拟。)当两个包独立提供
foo
foo.exe
时,或者更糟糕的是
dir/
dir.exe
时,这会导致 pacman 抱怨。人们必须忽略这些与
--force
的冲突,或者以特定顺序(重新)安装软件包。

解决这些冲突的一个可能的解决方案是禁用 .exe 插值,但这样就会出现问题,用户要么无法直接从 Windows 运行 MSYS2 可执行文件,要么无法使用无扩展名的短名称MSYS2 中的命令。

© www.soinside.com 2019 - 2024. All rights reserved.