{"record":{"id":"0b775eb7266d6dba","repo":"can1357/oh-my-pi","slug":"extra-operand-file-operands-cannot-be-combined-0b775e","errorCode":null,"errorMessage":"extra operand {}\nfile operands cannot be combined with --files0-from","messagePattern":"extra operand (.+?)\nfile operands cannot be combined with --files0-from","errorType":"error_code","errorClass":"WcError","httpStatus":null,"severity":"error","filePath":"crates/pi-builtins/src/wc.rs","lineNumber":785,"sourceCode":"\t\t\t\"never\" => Self::Never,\n\t\t\t_ => unreachable!(\"Should have been caught by clap\"),\n\t\t}\n\t}\n}\n\nimpl TotalWhen {\n\tfn is_total_row_visible(self, num_inputs: usize) -> bool {\n\t\tmatch self {\n\t\t\tSelf::Auto => num_inputs > 1,\n\t\t\tSelf::Always | Self::Only => true,\n\t\t\tSelf::Never => false,\n\t\t}\n\t}\n}\n\n#[derive(Debug, Error)]\nenum WcError {\n\t#[error(\"extra operand {}\\nfile operands cannot be combined with --files0-from\", extra.quote())]\n\tFilesDisabled { extra: Cow<'static, OsStr> },\n\t#[error(\"when reading file names from standard input, no file name of '-' allowed\")]\n\tStdinReprNotAllowed,\n\t#[error(\"invalid zero-length file name\")]\n\tZeroLengthFileName,\n\t#[error(\"{path}:{idx}: invalid zero-length file name\")]\n\tZeroLengthFileNameCtx { path: Cow<'static, str>, idx: usize },\n\t#[error(\"{context}: {source}\")]\n\tIo {\n\t\tcontext: String,\n\t\t#[source]\n\t\tsource:  io::Error,\n\t},\n}\n\nimpl WcError {\n\tfn zero_len(ctx: Option<(&Input, usize)>) -> Self {\n\t\tmatch ctx {","sourceCodeStart":767,"sourceCodeEnd":803,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/crates/pi-builtins/src/wc.rs#L767-L803","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Remove the extra positional operand; put every file name into the --files0-from list","Build the NUL-separated list programmatically (e.g. `find ... -print0 > list.txt`) and pass only that","Parse args so --files0-from and operands are mutually exclusive before calling wc"],"exampleFix":"// before: wc --files0-from=list.txt extra.txt\n// after\nprintf '%s\\0' extra.txt >> list.txt\nwc --files0-from=list.txt","handlingStrategy":"validation","validationCode":"fn validate_wc_args(files0_from: Option<&str>, operands: &[String]) -> Result<(), String> {\n    if files0_from.is_some() && !operands.is_empty() {\n        Err(format!(\"--files0-from cannot be combined with operands: {:?}\", operands))\n    } else { Ok(()) }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat --files0-from and positional operands as mutually exclusive in arg parsers","Merge all file names into the NUL-separated list instead of appending operands","Add a wrapper script check that fails fast when both are present"],"tags":["wc","cli-usage","argument-validation"],"backgroundTag":"conflicting-cli-options","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}