can1357/oh-my-pi · error · SeqError
format string may not be specified when printing equal width
Error message
format string may not be specified when printing equal width strings
What it means
This is the `FormatAndEqualWidth` variant of the seq error enum. GNU seq's `--equal-width` (`-w`) pads all numbers to equal width, which is incompatible with a user-supplied `--format` (`-f`) string, since the format already dictates output width. The library rejects the mutually exclusive combination up front.
Source
Thrown at crates/pi-builtins/src/seq.rs:448
///
/// The parameters are the [`String`] argument as read from the
/// command line and the underlying parsing error itself.
#[error("invalid {} argument: {}", parse_error_type(.1), .0.quote())]
ParseError(String, ParseNumberError),
/// The increment argument was zero, which is not allowed.
///
/// The parameter is the increment argument as a [`String`] as read
/// from the command line.
#[error("invalid Zero increment value: {}", .0.quote())]
ZeroIncrement(String),
/// 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 {
match e {
ParseNumberError::Float => "floating point",
ParseNumberError::Nan => "'not-a-number'",
}
}
}
use self::{error::SeqError, number::PreciseNumber};
const OPT_SEPARATOR: &str = "separator";
const OPT_TERMINATOR: &str = "terminator";
const OPT_EQUAL_WIDTH: &str = "equal-width";
const OPT_FORMAT: &str = "format";View on GitHub (pinned to 9690622007)
Solutions
- Remove the `--equal-width`/`-w` flag if you need a custom format.
- Remove the `--format`/`-f` string if you need equal-width padding; `-w` alone pads with the default format.
- Achieve custom formatting plus padding entirely in the format string, e.g. `-f '%3.0f'`.
- If options come from config/variables, make them mutually exclusive in your argument assembly logic.
Example fix
// before seq -f '%3.0f' -w 1 5 // after seq -f '%3.0f' 1 5
Defensive patterns
Strategy: validation
Validate before calling
let uses_format = args.iter().any(|a| a == "-f" || a == "--format");
let uses_equal_width = args.iter().any(|a| a == "-w" || a == "--equal-width");
if uses_format && uses_equal_width {
eprintln!("seq: -f and -w are mutually exclusive");
std::process::exit(2);
} Try / catch
match seq_result {
Err(SeqError::FormatAndEqualWidth) => eprintln!("drop either -f or -w; they cannot be combined"),
Err(e) => eprintln!("seq: {e}"),
Ok(out) => print!("{out}"),
} Prevention
- Treat -f/--format and -w/--equal-width as mutually exclusive options.
- Encode width/padding requirements fully in the -f format string when custom formatting is needed.
- Add an arg-parsing unit test for the conflicting combination in wrapper scripts.
When it happens
Trigger: Invoking the seq builtin with both a format string argument and the equal-width flag, e.g. `seq -f '%3.0f' -w 1 5`.
Common situations: Copy-pasted command lines where `-f` and `-w` accumulate from different option sources, or a user misunderstanding that `-w` and `-f` overlap in controlling output formatting.
Related errors
- missing operand
- unknown function: {0}
- unknown key binding function: {0}
- unimplemented: {0}
- I/O error occurred
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/f316b510b357e3fc.
Report an issue: GitHub.