mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
Merge pull request #7646 from drinkcat/seq-w-f
seq: Do not allow -w and -f to be specified at the same time
This commit is contained in:
commit
97fb15b02d
3 changed files with 16 additions and 0 deletions
|
@ -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 {
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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!()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue