can1357/oh-my-pi · error · SeqError

missing operand

Error message

missing operand

What it means

This error is the `NoArguments` variant of the seq error enum in the pi-builtins `seq` builtin. The `seq` command requires at least one numeric operand (the limit value); throwing with zero arguments would be ambiguous. It mirrors GNU seq's 'missing operand' diagnostic.

Source

Thrown at crates/pi-builtins/src/seq.rs:444

#[derive(Debug, Error)]
pub enum SeqError {
	/// An error parsing the input arguments.
	///
	/// 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};

View on GitHub (pinned to 9690622007)

Solutions

  1. Pass at least one argument: `seq <limit>` (e.g. `seq 10`).
  2. For a full range, supply the desired form: `seq <last>`, `seq <first> <last>`, or `seq <first> <increment> <last>`.
  3. In scripts, guard against empty variables before invoking seq (e.g. `${LIMIT:?LIMIT is unset}`).

Example fix

// before
seq()

// after
seq("10")
Defensive patterns

Strategy: validation

Validate before calling

if (args.is_empty()) {
    eprintln!("seq: missing operand");
    std::process::exit(1);
}
seq(&args);

Try / catch

match seq_result {
    Err(SeqError::NoArguments) => eprintln!("usage: seq <first> [increment] <last>"),
    Err(e) => eprintln!("seq: {e}"),
    Ok(out) => print!("{out}"),
}

Prevention

When it happens

Trigger: Calling the seq builtin with an empty argument list — no start, increment, or limit operand supplied at all.

Common situations: A script builds the seq invocation from variables that are all empty/unset, or a user runs `seq` interactively without any arguments.

Related errors


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/e1d99849db2ac639. Report an issue: GitHub.