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

shuf: include all echo args, not just the last #5978

Merged
merged 3 commits into from
Feb 17, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
shuf: include all echo args, not just the last
  • Loading branch information
BenWiederhake committed Feb 16, 2024
commit 07e8f4c7a5d7bf94aaf4f49cf86813a012fb8dcd
1 change: 1 addition & 0 deletions src/uu/shuf/src/shuf.rs
Original file line number Diff line number Diff line change
@@ -129,6 +129,7 @@ pub fn uu_app() -> Command {
.help("treat each ARG as an input line")
.use_value_delimiter(false)
.num_args(0..)
.action(clap::ArgAction::Append)
.conflicts_with(options::INPUT_RANGE),
)
.arg(
21 changes: 21 additions & 0 deletions tests/by-util/test_shuf.rs
Original file line number Diff line number Diff line change
@@ -79,6 +79,27 @@ fn test_echo() {
assert_eq!(result_seq, input_seq, "Output is not a permutation");
}

#[test]
fn test_echo_multi() {
let result = new_ucmd!()
.arg("-e")
.arg("a")
.arg("b")
.arg("-e")
.arg("c")
.succeeds();
result.no_stderr();

let mut result_seq: Vec<String> = result
.stdout_str()
.split('\n')
.filter(|x| !x.is_empty())
.map(|x| x.into())
.collect();
result_seq.sort_unstable();
assert_eq!(result_seq, ["a", "b", "c"], "Output is not a permutation");
}

#[test]
fn test_head_count() {
let repeat_limit = 5;