can1357/oh-my-pi · error · StatError

Invalid quoting style: {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.

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)

Solutions

  1. Use one of the supported quoting style values (e.g. literal, shell, c, escape) — correct any typo in the style argument.
  2. Check the stat builtin's help/docs for the exact accepted style names.
  3. Remove the style option if default quoting is acceptable.
  4. 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

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 option value errors: "must be one of", "is not a valid", and "only allows" failures explained — this error's family across 23 libraries.

Related errors


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/3a4ab7f094c06026. Report an issue: GitHub.