can1357/oh-my-pi · error · WcError

extra operand {} file operands cannot be combined with --fil

Error message

extra operand {}
file operands cannot be combined with --files0-from

What it means

WcError::FilesDisabled is thrown when positional file operands are supplied together with `--files0-from`. When file names come from a NUL-separated list, additional operand arguments are ambiguous and forbidden, matching GNU coreutils behavior.

Source

Thrown at crates/pi-builtins/src/wc.rs:785

			"never" => Self::Never,
			_ => unreachable!("Should have been caught by clap"),
		}
	}
}

impl TotalWhen {
	fn is_total_row_visible(self, num_inputs: usize) -> bool {
		match self {
			Self::Auto => num_inputs > 1,
			Self::Always | Self::Only => true,
			Self::Never => false,
		}
	}
}

#[derive(Debug, Error)]
enum WcError {
	#[error("extra operand {}\nfile operands cannot be combined with --files0-from", extra.quote())]
	FilesDisabled { extra: Cow<'static, OsStr> },
	#[error("when reading file names from standard input, no file name of '-' allowed")]
	StdinReprNotAllowed,
	#[error("invalid zero-length file name")]
	ZeroLengthFileName,
	#[error("{path}:{idx}: invalid zero-length file name")]
	ZeroLengthFileNameCtx { path: Cow<'static, str>, idx: usize },
	#[error("{context}: {source}")]
	Io {
		context: String,
		#[source]
		source:  io::Error,
	},
}

impl WcError {
	fn zero_len(ctx: Option<(&Input, usize)>) -> Self {
		match ctx {

View on GitHub (pinned to 9690622007)

Solutions

  1. Remove the extra positional operand; put every file name into the --files0-from list
  2. Build the NUL-separated list programmatically (e.g. `find ... -print0 > list.txt`) and pass only that
  3. Parse args so --files0-from and operands are mutually exclusive before calling wc

Example fix

// before: wc --files0-from=list.txt extra.txt
// after
printf '%s\0' extra.txt >> list.txt
wc --files0-from=list.txt
Defensive patterns

Strategy: validation

Validate before calling

fn validate_wc_args(files0_from: Option<&str>, operands: &[String]) -> Result<(), String> {
    if files0_from.is_some() && !operands.is_empty() {
        Err(format!("--files0-from cannot be combined with operands: {:?}", operands))
    } else { Ok(()) }
}

Prevention

When it happens

Trigger: Invoking wc like `wc --files0-from=list.txt extra.txt` — any extra operand after --files0-from triggers it, with the offending operand quoted in the message.

Common situations: Scripts that append default file arguments unconditionally while also enabling --files0-from; combining legacy operand lists with the newer --files0-from option during a migration.

Related errors


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