Skip to content

Commit 2b8e67b

Browse files
committed
ln: Allow hard links to soft links even when they poin to a directory
1 parent 0a5441f commit 2b8e67b

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/uu/ln/src/ln.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -434,8 +434,9 @@ fn link(src: &Path, dst: &Path, settings: &Settings) -> UResult<()> {
434434
if settings.symbolic {
435435
symlink(&source, dst)?;
436436
} else {
437-
// Cannot create hard link to a directory
438-
if src.is_dir() {
437+
// Cannot create hard link to a directory directly
438+
// We can however create hard link to a symlink that points to a directory, so long as -L is not passed
439+
if src.is_dir() && (!src.is_symlink() || settings.logical) {
439440
return Err(LnError::FailedToCreateHardLinkDir(source.to_path_buf()).into());
440441
}
441442

0 commit comments

Comments
 (0)