{"record":{"id":"54ae5717b69746c7","repo":"can1357/oh-my-pi","slug":"when-reading-file-names-from-standard-input-no-fi","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":"exception","errorClass":"SortError","httpStatus":null,"severity":"error","filePath":"crates/pi-builtins/src/sort.rs","lineNumber":2624,"sourceCode":"\tOpenTmpFileFailed { error: std::io::Error },\n\n\t#[error(\"could not run compress program '{}': {}\", .prog, strip_errno(.error))]\n\tCompressProgExecutionFailed { prog: String, error: std::io::Error },\n\n\t#[error(\"{} terminated abnormally\", .prog.quote())]\n\tCompressProgTerminatedAbnormally { prog: String },\n\n\t#[error(\"cannot create temporary file in {}:\", .path.quote())]\n\tTmpFileCreationFailed { path: PathBuf },\n\n\t#[error(\"extra operand {}\\nfile operands cannot be combined with --files0-from\\nTry 'sort --help' for more information.\", .file.quote())]\n\tFileOperandsCombined { file: PathBuf },\n\n\n\t#[error(\"multiple output files specified\")]\n\tMultipleOutputFiles,\n\n\t#[error(\"when reading file names from standard input, no file name of '-' allowed\")]\n\tMinusInStdIn,\n\n\t#[error(\"no input from {}\", .file.quote())]\n\tEmptyInputFile { file: PathBuf },\n\n\t#[error(\"{}:{}: invalid zero-length file name\", .file.maybe_quote(), .line_num)]\n\tZeroLengthFileName { file: PathBuf, line_num: usize },\n}\n\nimpl SortError {\n\tfn message(message: impl Into<String>) -> Self {\n\t\tSelf::Message(message.into())\n\t}\n\n\tfn code(&self) -> i32 {\n\t\tif matches!(self, Self::Disorder { .. }) { 1 } else { 2 }\n\t}\n}","sourceCodeStart":2606,"sourceCodeEnd":2642,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/crates/pi-builtins/src/sort.rs#L2606-L2642","documentation":"SortError::MinusInStdIn is thrown when the --files0-from list (read from standard input via `--files0-from=-`) contains the entry `-`. Since the list itself is already being read from stdin, `-` has no meaning as a file name and GNU-compatible sort rejects it explicitly.","triggerScenarios":"Piping a NUL-separated file list to `sort --files0-from=-` where one of the entries is the literal string `-`, e.g. `printf 'a.txt\\0-\\0' | sort --files0-from=-`.","commonSituations":"Generated file lists that include `-` as a placeholder for stdin; tools like find/du output post-processing where '-' sneaks in from other command conventions.","solutions":["Remove `-` entries from the NUL-separated list before feeding it to --files0-from=-.","Replace `-` with the actual path if a real file was intended.","Filter the list: e.g. `printf '%s\\0' ... | grep -zv '^-$' | sort --files0-from=-`."],"exampleFix":"// before\nprintf 'a.txt\\0-\\0b.txt\\0' | sort --files0-from=-\n// after\nprintf 'a.txt\\0b.txt\\0' | sort --files0-from=-","handlingStrategy":"validation","validationCode":"// sanitize a NUL-separated stdin list before --files0-from=-\nconst entries = list.split(\"\\0\").filter(e => e !== \"\" && e !== \"-\");\nconst cleaned = entries.join(\"\\0\") + \"\\0\";\n// pipe `cleaned` to sort --files0-from=-","typeGuard":"const isValidEntry = (e: string): boolean => e.length > 0 && e !== \"-\";","tryCatchPattern":"try {\n  await sort([\"--files0-from=-\"], { stdin: listStream });\n} catch (err) {\n  if (String(err).includes(\"no file name of '-' allowed\")) {\n    await sort([\"--files0-from=-\"], { stdin: stripMinusEntries(listStream) });\n  } else throw err;\n}","preventionTips":["Never include '-' as an entry when the list itself comes from stdin.","Filter generated lists for '-' placeholders before feeding --files0-from.","Build lists programmatically from real paths rather than manual strings.","Unit-test list generators against entries containing '-'."],"tags":["cli","sort","stdin","usage-error"],"backgroundTag":"invalid-input-entry","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}