diff --git a/src/uu/install/src/install.rs b/src/uu/install/src/install.rs index 51f0155910..38df659e4a 100644 --- a/src/uu/install/src/install.rs +++ b/src/uu/install/src/install.rs @@ -777,7 +777,7 @@ fn standard(mut paths: Vec, b: &Behavior) -> UResult<()> { return Err(InstallError::SameFile(source.clone(), target.clone()).into()); } - if target.is_file() || is_new_file_path(&target) { + if target.exists() || is_new_file_path(&target) { #[cfg(unix)] if let (Some(ref parent_fd), Some(ref filename)) = (target_parent_fd, target_filename) { if b.compare && !need_copy(source, &target, b) { diff --git a/tests/by-util/test_install.rs b/tests/by-util/test_install.rs index 71f2fb494f..3cd04f8aff 100644 --- a/tests/by-util/test_install.rs +++ b/tests/by-util/test_install.rs @@ -545,6 +545,22 @@ fn test_install_target_file_dev_null() { assert!(at.file_exists(file2)); } +#[test] +#[cfg(unix)] +fn test_install_replaces_special_target() { + let (at, mut ucmd) = at_and_ucmd!(); + let source = "source_file"; + let target = "target_fifo"; + + at.write(source, "contents"); + at.mkfifo(target); + + ucmd.arg(source).arg(target).succeeds().no_stderr(); + + assert!(at.file_exists(target)); + assert_eq!(at.read(target), "contents"); +} + #[test] fn test_install_nested_paths_copy_file() { let (at, mut ucmd) = at_and_ucmd!();