{"record":{"id":"69cfab031f61d4fc","repo":"can1357/oh-my-pi","slug":"using-to-denote-standard-input-does-not-work-i","errorCode":null,"errorMessage":"using '-' to denote standard input does not work in file system mode","messagePattern":"using '-' to denote standard input does not work in file system mode","errorType":"error_code","errorClass":"StatError","httpStatus":null,"severity":"error","filePath":"crates/pi-builtins/src/stat.rs","lineNumber":145,"sourceCode":"-`%t`: file system type in hex\n-`%T`: file system type in human readable form\n\nNOTE: your shell may have its own version of stat, which usually supersedes\nthe version described here.  Please refer to your shell's documentation\nfor details about the options it supports.\";\n\n\t#[derive(Debug, Error)]\n\tenum StatError {\n\t\t#[error(\"Invalid quoting style: {style}\")]\n\t\tInvalidQuotingStyle { style: String },\n\t\t#[error(\"missing operand\\nTry 'stat --help' for more information.\")]\n\t\tMissingOperand,\n\t\t#[error(\"{directive}: invalid directive\")]\n\t\tInvalidDirective { directive: String },\n\t\t#[error(\"cannot read table of mounted file systems: {error}\")]\n\t\t#[cfg_attr(not(unix), allow(dead_code, reason = \"mount tables are unix-only\"))]\n\t\tCannotReadFilesystem { error: String },\n\t\t#[error(\"using '-' to denote standard input does not work in file system mode\")]\n\t\t#[cfg_attr(not(unix), allow(dead_code, reason = \"stdin filesystem mode is unix-only\"))]\n\t\tStdinFilesystemMode,\n\t\t#[error(\"cannot read file system information for {file}: {error}\")]\n\t\tCannotReadFilesystemInfo { file: String, error: String },\n\t\t#[error(\"cannot stat {file}: {error}\")]\n\t\tCannotStat { file: String, error: String },\n\t}\n\n\tmod options {\n\t\tpub const DEREFERENCE: &str = \"dereference\";\n\t\tpub const FILE_SYSTEM: &str = \"file-system\";\n\t\tpub const FORMAT: &str = \"format\";\n\t\tpub const PRINTF: &str = \"printf\";\n\t\tpub const TERSE: &str = \"terse\";\n\t\tpub const BSD_SHELL: &str = \"bsd-shell\";\n\t\tpub const BSD_TIMEFMT: &str = \"bsd-timefmt\";\n\t\tpub const FILES: &str = \"files\";\n\t}","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/crates/pi-builtins/src/stat.rs#L127-L163","documentation":"This error (crates/pi-builtins/src/stat.rs, StdinFilesystemMode) is thrown when the user supplies '-' (standard input) as the operand while running stat in file-system mode. Stat file-system mode needs an actual filesystem path to look up the mount table entry; reading a path from stdin is not meaningful, matching GNU stat behavior. It is a usage/argument-validation error, not an I/O failure.","triggerScenarios":"Invoking the stat builtin with the `--file-system` option and '-' as the operand, e.g. piping data and running `echo / | stat --file-system -`.","commonSituations":"Scripts that build stat commands dynamically and pass '-' as a placeholder operand; porting GNU stat scripts where '-' handling differs between modes; pipelines where a filename is expected on stdin.","solutions":["Replace '-' with an actual filesystem path operand, e.g. `stat --file-system /`.","If stdin-based stat is desired, drop the --file-system option (plain stat mode accepts '-') and resolve the path yourself.","Guard scripts: only pass '-' to stat when file-system mode is off."],"exampleFix":"// before\nstat --file-system -\n\n// after\nstat --file-system /","handlingStrategy":"validation","validationCode":"if (useFsMode && operand === '-') {\n  throw new Error(\"stat file-system mode requires a real path, not '-'\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  await stat.run(['--file-system', operand]);\n} catch (err) {\n  if (String(err).includes(\"does not work in file system mode\")) {\n    console.error(`replace '-' with a filesystem path when using --file-system`);\n  } else throw err;\n}","preventionTips":["Never pass '-' as an operand together with --file-system.","Resolve stdin-provided paths to real paths before invoking stat.","Document the '-' restriction in wrapper scripts around stat."],"tags":["usage","stdin","filesystem","stat"],"backgroundTag":"invalid-operand-combination","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}