Skip to content
Merged
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
4 changes: 4 additions & 0 deletions src/uu/seq/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ pub enum SeqError {
/// No arguments were passed to this function, 1 or more is required
#[error("missing operand")]
NoArguments,

/// Both a format and equal width where passed to seq
#[error("format string may not be specified when printing equal width strings")]
FormatAndEqualWidth,
}

fn parse_error_type(e: &ParseNumberError) -> &'static str {
Expand Down
4 changes: 4 additions & 0 deletions src/uu/seq/src/seq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
format: matches.get_one::<String>(OPT_FORMAT).map(|s| s.as_str()),
};

if options.equal_width && options.format.is_some() {
return Err(SeqError::FormatAndEqualWidth.into());
}

let first = if numbers.len() > 1 {
match numbers[0].parse() {
Ok(num) => num,
Expand Down
8 changes: 8 additions & 0 deletions tests/by-util/test_seq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ fn test_no_args() {
.stderr_contains("missing operand");
}

#[test]
fn test_format_and_equal_width() {
new_ucmd!()
.args(&["-w", "-f", "%f", "1"])
.fails_with_code(1)
.stderr_contains("format string may not be specified");
}

#[test]
fn test_hex_rejects_sign_after_identifier() {
new_ucmd!()
Expand Down
Loading