mirror of
https://github.com/uutils/coreutils
synced 2024-11-16 09:48:03 +00:00
ln: adjust the error messages
This commit is contained in:
parent
676283ce93
commit
b3d87b088d
3 changed files with 7 additions and 7 deletions
|
@ -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 {
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue