can1357/oh-my-pi · error · StatError
Invalid quoting style
Error message
Invalid quoting style: {style} What it means
StatError::InvalidQuotingStyle is thrown by the stat builtin when the --printf quoting-style argument is not one of the supported styles. stat validates the requested style before formatting output and rejects unknown values, naming the style that was rejected.
Solutions
- Use one of the supported quoting style values (e.g. literal, shell, c, escape) — correct any typo in the style argument.
- Check the stat builtin's help/docs for the exact accepted style names.
- Remove the style option if default quoting is acceptable.
- Validate the style string in wrapper code before invoking stat.
Example fix
// before stat --printf='%n %s' --quoting-style=shelll file.txt // after stat --printf='%n %s' --quoting-style=shell file.txt
Defensive patterns
Strategy: validation
Validate before calling
// allow-list of quoting styles accepted by the stat builtin
const QUOTING_STYLES = new Set(["literal", "shell", "shell-always", "c", "escape", "locale", "c-maybe"]);
if (style !== undefined && !QUOTING_STYLES.has(style)) {
throw new Error(`Invalid quoting style: ${style}`);
} Type guard
const isQuotingStyle = (s: string): s is "literal" | "shell" | "shell-always" | "c" | "escape" | "locale" => ["literal", "shell", "shell-always", "c", "escape", "locale"].includes(s);
Try / catch
try {
await stat(["--quoting-style=" + style, file]);
} catch (err) {
if (String(err).startsWith("Invalid quoting style")) {
await stat([file]); // retry with default quoting
} else throw err;
} Prevention
- Keep quoting-style values in a typed constant/enum, never free-form strings.
- Validate style values at config-load time in wrapper scripts.
- Consult the stat builtin's help for the exact accepted style set.
- Test format/option combos after porting scripts between stat implementations.
When it happens
Trigger: Calling the stat builtin with `--printf=...` and a quoting-style value outside the accepted set (e.g. a typo like 'shelll' instead of 'shell', or an unsupported style string).
Common situations: Porting scripts between GNU stat variants with different accepted style vocabularies; typos in long option values; config files storing style names that were valid for another stat implementation.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- : invalid directive
- export requires --output
- export requires <scan-id> --output
- extra operand file operands cannot be combined with…
- import requires a SARIF file or Codex Security bundle…
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/3a4ab7f094c06026.
Report an issue: GitHub.
Appendix: source
Thrown at crates/pi-builtins/src/stat.rs:136
-`%b`: total data blocks in file system
-`%c`: total file nodes in file system
-`%d`: free file nodes in file system
-`%f`: free blocks in file system
-`%i`: file system ID in hex
-`%l`: maximum length of filenames
-`%n`: file name
-`%s`: block size (for faster transfers)
-`%S`: fundamental block size (for block counts)
-`%t`: file system type in hex
-`%T`: file system type in human readable form
NOTE: your shell may have its own version of stat, which usually supersedes
the version described here. Please refer to your shell's documentation
for details about the options it supports.";
#[derive(Debug, Error)]
enum StatError {
#[error("Invalid quoting style: {style}")]
InvalidQuotingStyle { style: String },
#[error("missing operand\nTry 'stat --help' for more information.")]
MissingOperand,
#[error("{directive}: invalid directive")]
InvalidDirective { directive: String },
#[error("cannot read table of mounted file systems: {error}")]
#[cfg_attr(not(unix), allow(dead_code, reason = "mount tables are unix-only"))]
CannotReadFilesystem { error: String },
#[error("using '-' to denote standard input does not work in file system mode")]
#[cfg_attr(not(unix), allow(dead_code, reason = "stdin filesystem mode is unix-only"))]
StdinFilesystemMode,
#[error("cannot read file system information for {file}: {error}")]
CannotReadFilesystemInfo { file: String, error: String },
#[error("cannot stat {file}: {error}")]
CannotStat { file: String, error: String },
}
mod options {View on GitHub (pinned to 9690622007)