From b3d87b088d3b5ba5f881d4377bab4ab53b5db707 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Thu, 31 Mar 2022 13:45:41 +0200 Subject: [PATCH] ln: adjust the error messages --- src/uu/ln/src/ln.rs | 10 +++++----- tests/by-util/test_ln.rs | 2 +- util/build-gnu.sh | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/uu/ln/src/ln.rs b/src/uu/ln/src/ln.rs index 378c89872..088edf219 100644 --- a/src/uu/ln/src/ln.rs +++ b/src/uu/ln/src/ln.rs @@ -54,7 +54,7 @@ enum LnError { TargetIsDirectory(PathBuf), SomeLinksFailed, FailedToLink(PathBuf, PathBuf, String), - SameFile(PathBuf, PathBuf), + SameFile(), MissingDestination(PathBuf), ExtraOperand(OsString), } @@ -66,8 +66,8 @@ impl Display for LnError { Self::FailedToLink(s, d, e) => { write!(f, "failed to link {} to {}: {}", s.quote(), d.quote(), e) } - Self::SameFile(e, e2) => { - write!(f, "{} and {} are the same file", e2.quote(), e.quote()) + Self::SameFile() => { + write!(f, "Same file") } Self::SomeLinksFailed => write!(f, "some links failed to create"), Self::MissingDestination(s) => { @@ -91,7 +91,7 @@ impl UError for LnError { Self::TargetIsDirectory(_) | Self::SomeLinksFailed | Self::FailedToLink(_, _, _) - | Self::SameFile(_, _) + | Self::SameFile() | Self::MissingDestination(_) | Self::ExtraOperand(_) => 1, } @@ -417,7 +417,7 @@ fn link(src: &Path, dst: &Path, settings: &Settings) -> UResult<()> { ResolveMode::Logical, )?; if dst_abs == source_abs { - return Err(LnError::SameFile(dst.to_path_buf(), source.to_path_buf()).into()); + return Err(LnError::SameFile().into()); } } if let Some(ref p) = backup_path { diff --git a/tests/by-util/test_ln.rs b/tests/by-util/test_ln.rs index f54ac5f39..0dcde3b35 100644 --- a/tests/by-util/test_ln.rs +++ b/tests/by-util/test_ln.rs @@ -622,7 +622,7 @@ fn test_backup_same_file() { at.touch("file1"); ucmd.args(&["--backup", "file1", "./file1"]) .fails() - .stderr_contains("'file1' and './file1' are the same file"); + .stderr_contains("n: failed to link 'file1' to './file1': Same file"); } #[test] diff --git a/util/build-gnu.sh b/util/build-gnu.sh index 4f02e8425..924d14d25 100755 --- a/util/build-gnu.sh +++ b/util/build-gnu.sh @@ -180,4 +180,4 @@ sed -i -e "s~ sed -n \"1s/'\\\/'/'OPT'/p\" < err >> pat || framework_failure_~ sed -i -e "s/rcexp=1$/rcexp=2\n case \"\$prg\" in chcon|dir|runcon|vdir) return;; esac/" tests/misc/usage_vs_getopt.sh # Update the GNU error message to match ours -sed -i -e "s/ln: 'f' and 'f' are the same file/ln: failed to link: 'f' and 'f' are the same file/g" tests/ln/hard-backup.sh +sed -i -e "s/ln: 'f' and 'f' are the same file/ln: failed to link 'f' to 'f': Same file/g" tests/ln/hard-backup.sh