Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions src/uu/base32/src/base_common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ pub fn base_app(about: String, usage: String) -> Command {
.short('w')
.long(options::WRAP)
.value_name("COLS")
// GNU takes the token after -w as the wrap size even when it starts with '-'.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// GNU takes the token after -w as the wrap size even when it starts with '-'.

Comment is unnecessary if you added test.

.allow_hyphen_values(true)
.help(translate!("base-common-help-wrap", "default" => WRAP_DEFAULT))
.overrides_with(options::WRAP),
)
Expand Down
14 changes: 14 additions & 0 deletions tests/by-util/test_base64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,20 @@ fn test_wrap_bad_arg() {
}
}

#[test]
fn test_wrap_negative_arg() {
// GNU consumes the token after -w as the wrap size even when it begins
// with '-', reporting it as an invalid wrap size rather than an unknown
// option.
for arg in ["-5", "-d"] {
new_ucmd!()
.arg("-w")
.arg(arg)
.fails()
.stderr_only(format!("base64: invalid wrap size: '{arg}'\n"));
}
}

#[test]
fn test_base64_extra_operand() {
// Expect a failure when multiple files are specified.
Expand Down
Loading