{"record":{"id":"54cff4b82f7aa024","repo":"can1357/oh-my-pi","slug":"extra-operand-file-operands-cannot-be-combined","errorCode":null,"errorMessage":"extra operand {}\nfile operands cannot be combined with --files0-from\nTry 'sort --help' for more information.","messagePattern":"extra operand (.+?)\nfile operands cannot be combined with --files0-from\nTry 'sort --help' for more information\\.","errorType":"exception","errorClass":"SortError","httpStatus":null,"severity":"error","filePath":"crates/pi-builtins/src/sort.rs","lineNumber":2617,"sourceCode":"\t#[error(\"open failed: {}: {}\", .path.maybe_quote(), strip_errno(.error))]\n\tOpenFailed { path: PathBuf, error: std::io::Error },\n\n\t#[error(\"cannot read: {}: {}\", .path.maybe_quote(), strip_errno(.error))]\n\tReadFailed { path: PathBuf, error: std::io::Error },\n\n\t#[error(\"failed to open temporary file: {}\", strip_errno(.error))]\n\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 {","sourceCodeStart":2599,"sourceCodeEnd":2635,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/crates/pi-builtins/src/sort.rs#L2599-L2635","documentation":"SortError::FileOperandsCombined is thrown when the user passes regular file operands together with --files0-from. GNU sort semantics forbid mixing: --files0-from supplies the input file list via a NUL-separated file, so no additional file operands may appear on the command line. The offending operand is included quoted.","triggerScenarios":"Calling the sort builtin with --files0-from=LIST and at least one positional file argument, e.g. `sort --files0-from=list.txt extra.txt`.","commonSituations":"Script migration where extra filenames were left over from a previous invocation; wrapping code that always appends a default input file; misunderstanding that --files0-from replaces rather than supplements operands.","solutions":["Remove all positional file operands when using --files0-from.","Put every input file name into the NUL-separated list consumed by --files0-from.","Use `-` inside the list if reading names from stdin (`--files0-from=-`).","If you only have a few inputs, drop --files0-from and pass them as plain operands instead."],"exampleFix":"// before\nsort --files0-from=list.txt extra.txt\n// after\nsort --files0-from=list.txt","handlingStrategy":"validation","validationCode":"// reject positional operands when --files0-from is set, before invoking sort\nif (args.includes(\"--files0-from\") && positionalFiles.length > 0) {\n  throw new Error(\"file operands cannot be combined with --files0-from\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  await sort(args, files);\n} catch (err) {\n  if (String(err).includes(\"files0-from\")) {\n    // rebuild argv: move all files into the NUL-separated list\n    await sort([\"--files0-from=\", toNulList(files)], []);\n  } else throw err;\n}","preventionTips":["Treat --files0-from as mutually exclusive with positional file args in any wrapper.","Generate NUL-separated input lists with find -print0 or printf '%s\\0'.","Add an argv lint in scripts that construct sort invocations dynamically.","Read sort --help before combining list-input flags with operands."],"tags":["cli","sort","usage-error","argument-validation"],"backgroundTag":"incompatible-cli-options","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}