{"record":{"id":"2c64974fa8570f6e","repo":"can1357/oh-my-pi","slug":"dired-and-zero-are-incompatible","errorCode":null,"errorMessage":"--dired and --zero are incompatible","messagePattern":"--dired and --zero are incompatible","errorType":"error_code","errorClass":"LsError","httpStatus":null,"severity":"error","filePath":"crates/pi-builtins/src/ls.rs","lineNumber":3705,"sourceCode":"\t\t\t1 => format!(\"cannot access {}: Operation not permitted\", .0.quote()),\n\t\t\t_ => if *.3 {\n\t\t\t\tformat!(\"cannot open directory {}: Permission denied\", .0.quote())\n\t\t\t} else {\n\t\t\t\tformat!(\"cannot open file {}: Permission denied\", .0.quote())\n\t\t\t},\n\t\t},\n\t\t_ => if 9 == .1.raw_os_error().unwrap_or(1) {\n\t\t\tformat!(\"cannot open directory {}: Bad file descriptor\", .0.quote())\n\t\t} else {\n\t\t\tformat!(\"unknown io error: {}, '{:?}'\", .0.quote(), .1)\n\t\t},\n\t})]\n\tIOErrorContext(PathBuf, std::io::Error, bool, bool),\n\n\t#[error(\"invalid --block-size argument '{0}'\")]\n\tBlockSizeParseError(String),\n\n\t#[error(\"--dired and --zero are incompatible\")]\n\tDiredAndZeroAreIncompatible,\n\n\t#[error(\"{}: not listing already-listed directory\", .0.maybe_quote())]\n\tAlreadyListedError(PathBuf),\n\n\t#[error(\"invalid --time-style argument {}\\nPossible values are:\\n  - [posix-]full-iso\\n  - [posix-]long-iso\\n  - [posix-]iso\\n  - [posix-]locale\\n  - +FORMAT (e.g., +%H:%M) for a 'date'-style format\\n\\nFor more information try --help\", .0.quote())]\n\tTimeStyleParseError(String),\n}\n\nimpl LsError {\n\tfn code(&self) -> i32 {\n\t\tmatch self {\n\t\t\tSelf::InvalidLineWidth(_) => 2,\n\t\t\tSelf::IOError(_) => 1,\n\t\t\tSelf::IOErrorContext(_, _, false, _) => 1,\n\t\t\tSelf::IOErrorContext(_, _, true, _) => 2,\n\t\t\tSelf::BlockSizeParseError(_) => 2,\n\t\t\tSelf::DiredAndZeroAreIncompatible => 2,","sourceCodeStart":3687,"sourceCodeEnd":3723,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/crates/pi-builtins/src/ls.rs#L3687-L3723","documentation":"LsError::DiredAndZeroAreIncompatible is raised when the builtin `ls` is invoked with both --dired and --zero. --dired emits per-file `//DIRED//` position markers for Emacs, which are meaningless (and would be wrong) when records are terminated by NUL instead of newline via --zero. The library rejects the combination up front, like GNU coreutils.","triggerScenarios":"Calling the ls builtin with both flags, e.g. `ls --dired --zero` or `ls -N --zero --dired` where one flag is set via an alias or LS_OPTIONS env var.","commonSituations":"Emacs dired-mode integration colliding with null-delimited output for `xargs -0` pipelines; shell aliases that always add --zero; combining options from two different sources without noticing the overlap.","solutions":["Remove --dired if you need machine-parseable NUL-delimited output (--zero)","Remove --zero if you need Emacs dired position markers (--dired)","Check aliases and LS_OPTIONS / ls wrapper scripts for an implicit --zero or --dired","Use plain tab/newline output if neither feature is actually needed"],"exampleFix":"// before\nls --dired --zero\n// after\nls --dired   // Emacs dired markers\n// or\nls --zero    // NUL-delimited for xargs -0","handlingStrategy":"validation","validationCode":"if (opts.includes('--dired') && opts.includes('--zero')) {\n  throw new Error('--dired and --zero are incompatible: pick one output convention');\n}","typeGuard":"const hasConflictingOutputFlags = (flags: string[]): boolean =>\n  flags.includes('--dired') && flags.includes('--zero');","tryCatchPattern":"try {\n  runLs(allFlags);\n} catch (e) {\n  if (String(e).includes('--dired and --zero are incompatible')) {\n    runLs(allFlags.filter(f => f !== '--dired'));\n  } else throw e;\n}","preventionTips":["Keep a whitelist of mutually exclusive flag pairs in tool wrappers","Audit aliases and LS_OPTIONS for hidden --zero/--dired","Validate combined flag sets before exec","Resolve the conflict deterministically (prefer --zero for piping)"],"tags":["cli","flag-conflict","ls"],"backgroundTag":"incompatible-cli-options","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}