{"record":{"id":"5e5abd8ede905bda","repo":"can1357/oh-my-pi","slug":"missing-operand-try-stat-help-for-more-informa","errorCode":null,"errorMessage":"missing operand\nTry 'stat --help' for more information.","messagePattern":"missing operand\nTry 'stat --help' for more information\\.","errorType":"exception","errorClass":"StatError","httpStatus":null,"severity":"error","filePath":"crates/pi-builtins/src/stat.rs","lineNumber":138,"sourceCode":"-`%d`: free file nodes in file system\n-`%f`: free blocks in file system\n-`%i`: file system ID in hex\n-`%l`: maximum length of filenames\n-`%n`: file name\n-`%s`: block size (for faster transfers)\n-`%S`: fundamental block size (for block counts)\n-`%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\";","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/crates/pi-builtins/src/stat.rs#L120-L156","documentation":"StatError::MissingOperand is thrown when the stat builtin is invoked with no file operands at all. stat requires at least one file (or '-' for stdin in filesystem mode) to report on, and the message follows the GNU convention of pointing the user at 'stat --help'.","triggerScenarios":"Running the stat builtin with only options and no path: `stat` or `stat --printf='%n'` with no positional argument.","commonSituations":"Shell variables holding paths that expanded to empty (`stat $UNSET_VAR`); pipelines where an upstream command produced no arguments; scripts that forgot a default path; wrapping code that drops empty args.","solutions":["Pass at least one file operand: `stat <file>`.","Quote/default the path variable: `stat \"${FILE:?path required}\"` or `stat \"${FILE:-.}\"`.","Check upstream command output if arguments are generated dynamically.","Read `stat --help` for expected usage."],"exampleFix":"// before\nFILE=\"\"\nstat $FILE\n// after\nFILE=\"./target.txt\"\nstat \"$FILE\"","handlingStrategy":"validation","validationCode":"// require at least one operand before invoking stat\nif (operands.length === 0) {\n  throw new Error(\"stat: missing operand — pass at least one file path\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  await stat(args);\n} catch (err) {\n  if (String(err).includes(\"missing operand\")) {\n    // default to current directory entry or fail with a clear message\n    if (!file) throw new Error(\"no file given to stat\");\n    return stat([file, ...args]);\n  } else throw err;\n}","preventionTips":["Always quote path variables: stat \"$FILE\".","Use ${FILE:?} in shell to abort on unset paths before invoking stat.","Validate operand arrays are non-empty in wrappers before spawning.","Set default paths where an empty operand is acceptable."],"tags":["stat","cli","missing-argument","usage-error"],"backgroundTag":"missing-required-argument","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}