mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
readlink: symlink loop handling (#3717)
readlink: fix symlink loop handling
This commit is contained in:
parent
882cd527ff
commit
0ea3a735ca
2 changed files with 12 additions and 1 deletions
|
@ -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");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue