uutils / coreutils

Cross-platform Rust rewrite of the GNU coreutils
https://uutils.github.io/
MIT License
17.69k stars 1.27k forks source link

`install`: Accept special files like `/dev/stdin` #5080

Open TheDcoder opened 1 year ago

TheDcoder commented 1 year ago

GNU coreutils accepts special files like /dev/stdin without any issues, for e.g.:

$ echo 'foo' | install /dev/stdin test

That creates a file called test with foo\n as its contents, which isn't surprising.

However our coreutils fail with the same usage with this error:

install: cannot install '/dev/stdin' to 'test': Invalid input parameter

This issue doesn't effect cp, however it might effect other utils which haven't been tested.

TheDcoder commented 1 year ago

Found in the wild here:

echo 'g keyd' | install -Dm644 /dev/stdin "${pkgdir}/usr/lib/sysusers.d/${pkgname%-git}.conf"
tertsdiepraam commented 1 year ago

I checked the source code and install just uses std::fs::copy, which indeed doesn't handle that case. cp has a more complicated procedure which falls back to copying the contents. I think it might make sense to extract that procedure to uucore and share it between the two utils. Could also be fun to make it a separate crate later too, because it might be useful for other projects to have a more flexible copy function, but let's start with uucore.

granquet commented 1 year ago

Wondering if this (moving cp code to uucore) could be a good "first step" for https://github.com/uutils/coreutils/issues/5203 ?

Javatrix commented 2 months ago

Checked right now, works correctly. Perhaps the issue should be closed?

TheDcoder commented 2 months ago

What fixed the issue? :thinking:

Javatrix commented 2 months ago

I don't know, but this issue seems to be quite old. Perhaps somebody fixed it and forgot to mark this as complete.