mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
readlink: symlink loop handling (#3717)
readlink: fix symlink loop handling
This commit is contained in:
@@ -84,7 +84,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
if verbose {
|
||||
return Err(USimpleError::new(
|
||||
1,
|
||||
format!("{}: errno {}", f.maybe_quote(), err.raw_os_error().unwrap()),
|
||||
err.map_err_context(move || f.maybe_quote().to_string())
|
||||
.to_string(),
|
||||
));
|
||||
} else {
|
||||
return Err(1.into());
|
||||
|
||||
@@ -70,3 +70,13 @@ fn test_long_redirection_to_root() {
|
||||
println!("expect: {:?}", expect);
|
||||
assert_eq!(actual, expect);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_symlink_to_itself_verbose() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
at.relative_symlink_file("a", "a");
|
||||
ucmd.args(&["-ev", "a"])
|
||||
.fails()
|
||||
.code_is(1)
|
||||
.stderr_contains("Too many levels of symbolic links");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user