Skip to content

install: accept piped input when replacing an existing file - #15438

Merged
sylvestre merged 1 commit into
uutils:mainfrom
limadog9:fix/install-piped-input
Oct 22, 2026
Merged

sylvestre merged 1 commit into
uutils:mainfrom
limadog9:fix/install-piped-input

Conversation

@limadog9

Copy link
Copy Markdown
Contributor

Allow piped /dev/stdin and /dev/fd/0 sources when replacing an existing file, including with backups and -D. Preserve same-file checks and open the source before removing the destination.

Closes #12407

Comment thread src/uu/install/src/install.rs Outdated
);
}

let mut handle = File::open(from)?;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this move needed for the pipe case? copy_file_safe still unlinks first

Comment thread tests/by-util/test_install.rs Outdated
if create_leading {
ucmd.arg("-D");
}
ucmd.arg("/dev/fd/0")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you also test /dev/stdin? it's the one from the issue

@limadog9
limadog9 force-pushed the fix/install-piped-input branch from 704245b to 8c6807c Compare October 17, 2026 12:40
@limadog9

Copy link
Copy Markdown
Contributor Author

@sylvestre Thanks, you’re right—the source-open move wasn’t needed for the pipe fix, so I removed it. The test now covers both /dev/stdin and /dev/fd/0, including existing targets, backups, and -D.

@limadog9
limadog9 force-pushed the fix/install-piped-input branch from 8c6807c to af4a50c Compare October 17, 2026 14:50

#[test]
#[rstest::rstest]
#[cfg(unix)]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please move #[cfg(unix)] above #[rstest::rstest]? here rstest applies it only to the fd case

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

@limadog9
limadog9 force-pushed the fix/install-piped-input branch from af4a50c to 8a2c55d Compare October 18, 2026 22:34
@sylvestre
sylvestre merged commit 7222c26 into uutils:main Oct 22, 2026
98 of 99 checks passed
@sylvestre

Copy link
Copy Markdown
Contributor

Thanks for your PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

install with piped input fails if target file exists

2 participants