{"record":{"id":"2e287186b3da4ed4","repo":"can1357/oh-my-pi","slug":"when-reading-file-names-from-standard-input-no-fi-2e2871","errorCode":null,"errorMessage":"when reading file names from standard input, no file name of '-' allowed","messagePattern":"when reading file names from standard input, no file name of '-' allowed","errorType":"error_code","errorClass":"WcError","httpStatus":null,"severity":"error","filePath":"crates/pi-builtins/src/wc.rs","lineNumber":787,"sourceCode":"\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 {\n\t\t\tSome((input, idx)) => {\n\t\t\t\tlet path = match input {","sourceCodeStart":769,"sourceCodeEnd":805,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/crates/pi-builtins/src/wc.rs#L769-L805","documentation":"WcError::StdinReprNotAllowed fires when the literal '-' (stdin marker) appears among the file names read from a `--files0-from` list. Since the names themselves come from stdin, a nested '-' stdin reference is undefined and coreutils forbids it.","triggerScenarios":"Running `wc --files0-from=list.txt` where list.txt contains a NUL-delimited '-' entry (e.g. produced by a pipeline that echoed '-'), or passing '-' through find/xargs output into the list.","commonSituations":"Accidentally including '-' in generated file lists; reusing an operand list built for plain `wc -` invocations; scripts substituting '-' as a placeholder for stdin.","solutions":["Remove the '-' entry from the --files0-from list file","If stdin content must be counted, run a separate `wc` on stdin (possibly writing it to a temp file and adding that to the list)","Filter the list before use: `grep -zvx -- '-' list.txt > list.clean`"],"exampleFix":"// before: list.txt contains \"a.txt\\0-\\0b.txt\\0\"\n// after\ngrep -zvx -- '-' list.txt > list.clean && wc --files0-from=list.clean","handlingStrategy":"validation","validationCode":"fn validate_files0_list(bytes: &[u8]) -> Result<(), String> {\n    let names: Vec<&[u8]> = bytes.split(|&b| b == 0).filter(|s| !s.is_empty()).collect();\n    if names.iter().any(|n| n == b\"-\") {\n        Err(\"'-' is not allowed inside --files0-from input\".into())\n    } else { Ok(()) }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Filter '-' from generated lists before passing them to --files0-from","Count stdin content with a separate plain `wc` invocation","Never reuse operand-style file lists (which may contain '-') as --files0-from input"],"tags":["wc","cli-usage","stdin","files0-from"],"backgroundTag":"conflicting-cli-options","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}