Skip to content

cp: set status code when encountering circular symbolic links#9757

Merged
Ecordonnier merged 24 commits intouutils:mainfrom
Thanhphan1147:main
Jan 6, 2026
Merged

cp: set status code when encountering circular symbolic links#9757
Ecordonnier merged 24 commits intouutils:mainfrom
Thanhphan1147:main

Conversation

@Thanhphan1147
Copy link
Contributor

Fixes #9710

Change from using the show_error! macro to the show! macro which correctly sets the status code.

Added a new test to validate this behavior.

ucmd.arg(source_dir)
.arg(target_dir)
.arg("-rL")
.fails_with_code(1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please also verify the output

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the test to check for the output. I did not check for an exact match of the stderr since I think they might differ slightly depending on the OS and "Too many levels of symbolic links" should be a good enough indicator that the command is outputting what we expect I think.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't want to make the test to complex and test for the full output for the different OSes so I updated the test to simply check for the string from walkdir.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the tests again to include windows-specific syntax for the error message

@github-actions
Copy link

GNU testsuite comparison:

Congrats! The gnu test tests/basenc/bounded-memory is now passing!

@github-actions
Copy link

GNU testsuite comparison:

Congrats! The gnu test tests/tty/tty-eof is no longer failing!

@github-actions
Copy link

GNU testsuite comparison:

Note: The gnu test tests/printf/printf-surprise is now being skipped but was previously passing.

@github-actions
Copy link

GNU testsuite comparison:

Note: The gnu test tests/id/smack was skipped on 'main' but is now failing.
Note: The gnu test tests/mkdir/smack-no-root was skipped on 'main' but is now failing.
Note: The gnu test tests/mkdir/smack-root was skipped on 'main' but is now failing.

@github-actions
Copy link

GNU testsuite comparison:

Note: The gnu test tests/id/smack was skipped on 'main' but is now failing.
Note: The gnu test tests/mkdir/smack-no-root was skipped on 'main' but is now failing.
Note: The gnu test tests/mkdir/smack-root was skipped on 'main' but is now failing.

@Thanhphan1147
Copy link
Contributor Author

Fixed the merge conflicts.

@github-actions
Copy link

github-actions bot commented Jan 4, 2026

GNU testsuite comparison:

Skipping an intermittent issue tests/timeout/timeout (passes in this run but fails in the 'main' branch)

@github-actions
Copy link

github-actions bot commented Jan 4, 2026

GNU testsuite comparison:

Skipping an intermittent issue tests/timeout/timeout (passes in this run but fails in the 'main' branch)

@Ecordonnier Ecordonnier self-requested a review January 4, 2026 21:12
@github-actions
Copy link

github-actions bot commented Jan 5, 2026

GNU testsuite comparison:

Congrats! The gnu test tests/basenc/bounded-memory is now passing!
Note: The gnu test tests/dd/no-allocate was skipped on 'main' but is now failing.

@Thanhphan1147
Copy link
Contributor Author

Fixed the formatting issue.

@github-actions
Copy link

github-actions bot commented Jan 5, 2026

GNU testsuite comparison:

Congrats! The gnu test tests/basenc/bounded-memory is now passing!
Note: The gnu test tests/dd/no-allocate was skipped on 'main' but is now failing.

@Ecordonnier Ecordonnier self-assigned this Jan 5, 2026
@github-actions
Copy link

github-actions bot commented Jan 5, 2026

GNU testsuite comparison:

Skipping an intermittent issue tests/timeout/timeout (passes in this run but fails in the 'main' branch)
Note: The gnu test tests/basenc/bounded-memory is now being skipped but was previously passing.

@github-actions
Copy link

github-actions bot commented Jan 5, 2026

GNU testsuite comparison:

Skip an intermittent issue tests/timeout/timeout (fails in this run but passes in the 'main' branch)
Congrats! The gnu test tests/dd/nocache_eof is no longer failing!

@Thanhphan1147
Copy link
Contributor Author

Fixed the conflicts with the tests

@github-actions
Copy link

github-actions bot commented Jan 5, 2026

GNU testsuite comparison:

Skip an intermittent issue tests/timeout/timeout (fails in this run but passes in the 'main' branch)
Congrats! The gnu test tests/dd/nocache_eof is no longer failing!

@Ecordonnier Ecordonnier merged commit 7274e7f into uutils:main Jan 6, 2026
131 checks passed
sgmarz pushed a commit to sgmarz/coreutils that referenced this pull request Jan 7, 2026
…#9757)

* cp: set exit code when encountering circular symbolic links error when copying directory

* cp: add test to ensure that cp sets the status code when encountering circular symbolic links during directory copy

* cp: check that the output of circular symbolic link test has the correct message

* cp: update check for stderr message

* cp: update circular symbolic link test to account for directory format in windows

* cp: use std::path::MAIN_SEPARATOR_STR for test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cp -rL returns exit code 0 when encountering circular symbolic links error

3 participants