8000 unexpand: add -f short alias for --first-only by GTimothy · Pull Request #8229 · uutils/coreutils · GitHub
[go: up one dir, main page]

Skip to content

unexpand: add -f short alias for --first-only #8229

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

Merged
merged 2 commits into from
Jun 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

8000
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/src/extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,3 +193,8 @@ Just like on macOS, `base32/base64/basenc` provides `-D` to decode data.
## `shred`

The number of random passes is deterministic in both GNU and uutils. However, uutils `shred` computes the number of random passes in a simplified way, specifically `max(3, x / 10)`, which is very close but not identical to the number of random passes that GNU would do. This also satisfies an expectation that reasonable users might have, namely that the number of random passes increases monotonically with the number of passes overall; GNU `shred` violates this assumption.

## `unexpand`

GNU `unexpand` provides `--first-only` to convert only leading sequences of blanks. We support a
second way: `-f` like busybox.
1 change: 1 addition & 0 deletions src/uu/unexpand/src/unexpand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ pub fn uu_app() -> Command {
)
.arg(
Arg::new(options::FIRST_ONLY)
.short('f')
.long(options::FIRST_ONLY)
.help(get_message("unexpand-help-first-only"))
.action(ArgAction::SetTrue),
Expand Down
18 changes: 18 additions & 0 deletions tests/by-util/test_unexpand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,24 @@ fn unexpand_first_only_1() {
.stdout_is("\t\t A B");
}

#[test]
fn unexpand_first_only_2() {
new_ucmd!()
.args(&["-t3", "-f"])
.pipe_in(" A B")
.succeeds()
.stdout_is("\t\t A B");
}

#[test]
fn unexpand_first_only_3() {
new_ucmd!()
.args(&["-f", "-t8"])
.pipe_in(" A B")
.succeeds()
.stdout_is("\tA B");
}

#[test]
fn unexpand_trailing_space_0() {
// evil
Expand Down
Loading
0