Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

install: no output when running -s --strip-program #5718

Closed
cakebaker opened this issue Dec 24, 2023 · 4 comments · Fixed by #5848
Closed

install: no output when running -s --strip-program #5718

cakebaker opened this issue Dec 24, 2023 · 4 comments · Fixed by #5848
Labels

Comments

@cakebaker
Copy link
Contributor

cakebaker commented Dec 24, 2023

While reviewing #5697, I noticed that GNU install outputs ./-dest when running install -s --strip-program ./no-hyphen -- source -dest whereas uutils install doesn't output anything.

The no-hyphen program is (from test_install_and_strip_with_program_hyphen):

#!/bin/sh
printf -- '%s\n' "$1" | grep '^[^-]'
@sylvestre sylvestre added the good first issue For newcomers! label Dec 24, 2023
@cre4ture
Copy link
Contributor

I tried to reproduce. But to me it looks like the file is created as expected. Can you please re-check or describe more in detail?

uli@hp13-ulix:~/dev_rust/coreutils/testdir_install$ ls     
no-hyphen  src
uli@hp13-ulix:~/dev_rust/coreutils/testdir_install$ ~/dev_rust/coreutils/target/debug/install -s --strip-program ./no-hyphen -- src -dest
uli@hp13-ulix:~/dev_rust/coreutils/testdir_install$ ls -lah
total 12K
-rwxr-xr-x  1 uli uli    0 Jan 15 21:58 -dest
drwxrwxr-x  2 uli uli 4.0K Jan 15 21:58 .
drwxrwxr-x 15 uli uli 4.0K Jan 15 21:35 ..
-rwxrwxr-x  1 uli uli   48 Jan 15 21:39 no-hyphen
-rw-rw-r--  1 uli uli    0 Jan 15 21:40 src
uli@hp13-ulix:~/dev_rust/coreutils/testdir_install$ ls
-dest  no-hyphen  src
uli@hp13-ulix:~/dev_rust/coreutils/testdir_install$ 

@cakebaker
Copy link
Contributor Author

The issue is that the following statement produces no output on stdout:

uli@hp13-ulix:~/dev_rust/coreutils/testdir_install$ ~/dev_rust/coreutils/target/debug/install -s --strip-program ./no-hyphen -- src -dest

GNU install outputs ./-dest. And if the destination doesn't start with a -, it simply outputs the destination.

I hope this clarifies the issue.

@cre4ture
Copy link
Contributor

cre4ture commented Jan 16, 2024

Ok, thanks for clarification. I think I finally understood the test.
Next problem: I can't reproduce the described GNU behavior on my machine:

$ install -s --strip-program ./no-hyphen -- src -dest
install: strip process terminated abnormally

After forcing the return code of "./no-hypen" to 0, I get this:

$ install -s --strip-program ./no-hyphen -- src -dest
$ install -s --strip-program ./no-hyphen -- src dest
dest
$ install -s --strip-program ./no-hyphen -- src -dest
$ install -s --strip-program ./no-hyphen -- src ./-dest
./-dest
$ install --version
install (GNU coreutils) 8.32
...

So GNU only outputs "./-dest" when this is provided exactly like this as input.

$ ~/dev_rust/coreutils/target/debug/install -s --strip-program ./no-hyphen -- src -dest
$ ~/dev_rust/coreutils/target/debug/install -s --strip-program ./no-hyphen -- src ./-dest
$ install -s --strip-program ./no-hyphen -- src ./-dest
./-dest

Sadly, uutils doesn't even output it in that case.

a) It seems to me that the more critical issue is that uutils is not validating the return code of "./no-hyphen".
b) I don't get why the starting "-" is such a important usecase? The destinatio file is created the correct way, or?

@cre4ture
Copy link
Contributor

I think I found the issue. uutils does the right thing. It just doesn't forward the stdout accordingly.
I'll provide a fix.

cakebaker pushed a commit that referenced this issue Jan 17, 2024
… (#5848)

* Fix missing dependency to "process" to make it compile.

* fix issue of not forwarding stdout from strip program

* fix issue of applying "./" redundantly

* cargo fmt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants