mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
seq: Do not allow -w and -f to be specified at the same time
Fixes #7466.
This commit is contained in:
parent
d6cf38ff3f
commit
ae3756b434
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
|
/// No arguments were passed to this function, 1 or more is required
|
||||||
#[error("missing operand")]
|
#[error("missing operand")]
|
||||||
NoArguments,
|
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 {
|
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()),
|
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 {
|
let first = if numbers.len() > 1 {
|
||||||
match numbers[0].parse() {
|
match numbers[0].parse() {
|
||||||
Ok(num) => num,
|
Ok(num) => num,
|
||||||
|
|
|
@ -19,6 +19,14 @@ fn test_no_args() {
|
||||||
.stderr_contains("missing operand");
|
.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]
|
#[test]
|
||||||
fn test_hex_rejects_sign_after_identifier() {
|
fn test_hex_rejects_sign_after_identifier() {
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue