フィルターのクリア

Strange behavior of `copyfile` regarding symlinks on Linux and macOS

3 ビュー (過去 30 日間)
Zaikun Zhang
Zaikun Zhang 2023 年 10 月 22 日
編集済み: Zaikun Zhang 2023 年 11 月 21 日
Consider the following function.
%test_copyfile.m
function test_copyfile()
system('rm -rf folder*; mkdir folder1; cd folder1; touch a b c d e f g; ln -s d dlink; rm d; cd ..');
success = copyfile('folder1','folder2');
assert(success);
fprintf('\nfolder1:\n');
dir('folder1')
fprintf('\nfolder2:\n');
dir('folder2')
assert(isequal({dir('folder1').name}, {dir('folder2').name}));
return
Running it in MATLAB R2023b on Ubuntu 22.04 or macOS 13 (Intel chip), I got the following result.
folder1:
. .. a b c dlink e f g
folder2:
. .. b f
Error using assert
Assertion failed.
Error in test_copyfile (line 14)
assert(isequal({dir('folder1').name}, {dir('folder2').name}));
The test has been conducted on a few machines. It seems that the content of folder2 is not deterministic. Sometimes, it may be
folder2:
. .. a g
or
folder2:
. ..
But I have not recognized the pattern.
Is this expected? Thanks.

採用された回答

Zaikun Zhang
Zaikun Zhang 2023 年 10 月 31 日
編集済み: Zaikun Zhang 2023 年 11 月 21 日
Update 20231031: Below is the response from MathWorks support.
"
Please be assured that this has been confirmed as a bug and is currently under thorough investigation by our development team. In the meantime, I have taken the initiative to attach your contact information to the relevant internal request. This ensures that you will be promptly notified when the bug is resolved in future releases.
"

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeIntroduction to Installation and Licensing についてさらに検索

製品


リリース

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by