can1357/oh-my-pi · error · WcError
when reading file names from standard input, no file name of
Error message
when reading file names from standard input, no file name of '-' allowed
What it means
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.
Source
Thrown at crates/pi-builtins/src/wc.rs:787
}
}
}
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 {
Some((input, idx)) => {
let path = match input {View on GitHub (pinned to 9690622007)
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`
Example fix
// before: list.txt contains "a.txt\0-\0b.txt\0" // after grep -zvx -- '-' list.txt > list.clean && wc --files0-from=list.clean
Defensive patterns
Strategy: validation
Validate before calling
fn validate_files0_list(bytes: &[u8]) -> Result<(), String> {
let names: Vec<&[u8]> = bytes.split(|&b| b == 0).filter(|s| !s.is_empty()).collect();
if names.iter().any(|n| n == b"-") {
Err("'-' is not allowed inside --files0-from input".into())
} else { Ok(()) }
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: Accidentally including '-' in generated file lists; reusing an operand list built for plain `wc -` invocations; scripts substituting '-' as a placeholder for stdin.
Related errors
- invalid zero-length file name
- extra operand {} file operands cannot be combined with --fil
- {path}:{idx}: invalid zero-length file name
- Overlapping replacements detected; refine pattern to avoid a
- when reading file names from standard input, no file name of
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/2e287186b3da4ed4.
Report an issue: GitHub.