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

sort: accepts multiple -o arguments but shouldn't #7183

Open
jfinkels opened this issue Jan 20, 2025 · 4 comments · May be fixed by #7199
Open

sort: accepts multiple -o arguments but shouldn't #7183

jfinkels opened this issue Jan 20, 2025 · 4 comments · May be fixed by #7199
Labels

Comments

@jfinkels
Copy link
Collaborator

Environment: Ubuntu 20.04, uutils main branch (git commit 6a5f2aa), GNU coreutils v8.30

Steps to reproduce:

sort -o x -o y

What happens now: uutils sort waits for input and then writes the output to y (ignoring the -o x argument).

What I expected to happen: GNU sort terminates with an error message because at most one output file is allowed:

sort: multiple output files specified

Notes: this is causing a failure in GNU test file tests/sort/sort.pl.

@AbhinavMir
Copy link
Contributor

So my approach here shud be in src/uu/sort/src/main.rs

  • Add logic to track if an output file has already been specified
  • Return an error with the message "sort: multiple output files specified" if multiple output files are attempted
  • The error should occur before any sorting takes place
  • Update tests/sort/sort.pl
    Did I get that right?

@AbhinavMir AbhinavMir linked a pull request Jan 23, 2025 that will close this issue
@AbhinavMir
Copy link
Contributor

@jfinkels How can I test this?

Notes: this is causing a failure in GNU test file tests/sort/sort.pl.
Is there a way for me to test this locally? I ran this locally and the output is as expected.

@sylvestre
Copy link
Contributor

to run the GNU test:
bash util/build-gnu.sh && bash -v util/run-gnu-test.sh tests/sort/sort.pl

@cakebaker cakebaker linked a pull request Jan 23, 2025 that will close this issue
@AbhinavMir
Copy link
Contributor

Thanks @sylvestre on it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants