Skip to content

Commit d05460a

Browse files
authored
unexpand: add -f short alias for --first-only (#8229)
1 parent 39c793c commit d05460a

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

docs/src/extensions.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,3 +193,8 @@ Just like on macOS, `base32/base64/basenc` provides `-D` to decode data.
193193
## `shred`
194194

195195
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.
196+
197+
## `unexpand`
198+
199+
GNU `unexpand` provides `--first-only` to convert only leading sequences of blanks. We support a
200+
second way: `-f` like busybox.

src/uu/unexpand/src/unexpand.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ pub fn uu_app() -> Command {
175175
)
176176
.arg(
177177
Arg::new(options::FIRST_ONLY)
178+
.short('f')
178179
.long(options::FIRST_ONLY)
179180
.help(get_message("unexpand-help-first-only"))
180181
.action(ArgAction::SetTrue),

tests/by-util/test_unexpand.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,24 @@ fn unexpand_first_only_1() {
9595
.stdout_is("\t\t A B");
9696
}
9797

98+
#[test]
99+
fn unexpand_first_only_2() {
100+
new_ucmd!()
101+
.args(&["-t3", "-f"])
102+
.pipe_in(" A B")
103+
.succeeds()
104+
.stdout_is("\t\t A B");
105+
}
106+
107+
#[test]
108+
fn unexpand_first_only_3() {
109+
new_ucmd!()
110+
.args(&["-f", "-t8"])
111+
.pipe_in(" A B")
112+
.succeeds()
113+
.stdout_is("\tA B");
114+
}
115+
98116
#[test]
99117
fn unexpand_trailing_space_0() {
100118
// evil

0 commit comments

Comments
 (0)