Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Heuristic:20000419 Fauxnix Fail Loud Discipline

From Leeroopedia
Knowledge Sources
Domains Error_Handling, CLI, Validation
Last Updated 2026-10-26 00:00 GMT

Overview

Unsupported bash constructs and unknown/unsupported command options throw named errors with GNU-style usage messages instead of silently passing through or producing wrong output.

Description

Fauxnix follows a fail-loud philosophy: when the parser or registry encounters something it cannot handle, it throws a named `FauxnixParseError` or returns a GNU-style usage error — never a silent wrong result. The parser throws `FauxnixParseError('fauxnix: unsupported redirect: ' + op)` for unsupported redirect operators. The command registry's spec'd commands fail loud on unknown or unsupported options, emitting messages like `unrecognized option '--foo'`, `invalid option -- 'z'`, or `option '--bar' doesn't allow an argument` — exactly mirroring GNU coreutils behavior. This design lets AI agents pattern-match on familiar Linux error styles rather than debugging mysterious PowerShell output.

Usage

Apply this heuristic when designing command translation or any surface where unsupported input might be encountered. The rule: never silently produce wrong output. Either translate correctly, or throw a named error with a message the caller can recognize and act on.

The Insight (Rule of Thumb)

  • Action: Throw `FauxnixParseError` for unsupported grammar constructs; return GNU-style usage errors for unknown/unsupported command options.
  • Value: Error messages match GNU coreutils conventions (`unrecognized option '...'`, `invalid option -- '...'`, `option '...' doesn't allow an argument`).
  • Trade-off: Some bash constructs that "might work" are rejected rather than risked; users must adapt their command.
  • Compatibility: Unknown commands (git, node, npm, python) still pass through natively — fail-loud applies to supported commands with unsupported options, not to unknown commands.

Reasoning

AI agents and developers rely on recognizable error messages to debug failed commands. If fauxnix silently produced wrong output (e.g., ignoring an unsupported flag), the agent would see a successful exit code with incorrect results — far harder to debug than a clear error. By matching GNU coreutils error text, fauxnix ensures that error-handling logic written for real bash works unchanged. The distinction between "unsupported option on a known command" (fail loud) and "unknown command" (pass through) is deliberate: known commands have defined semantics that could be violated by wrong flags, while unknown commands are opaque passthrough.

Code Evidence

Parser fail-loud for unsupported redirects from `src/parser.ts:1535`:

throw new FauxnixParseError('fauxnix: unsupported redirect: ' + op);

Registry GNU-style option validation from `src/registry.ts:520-550`:

if (t.startsWith('--')) {
  const eq = t.indexOf('=');
  const name = eq >= 0 ? t.slice(0, eq) : t;
  const opt = longs.get(name);
  if (!opt) return fail("unrecognized option '" + name + "'");
  if (opt.support === 'unsupported') {
    return fail(unsupportedMsg(opt, name));
  }
  if (!opt.takesValue && eq >= 0) {
    return fail("option '" + name + "' doesn't allow an argument");
  }
  if (opt.takesValue && eq < 0) {
    if (i + 1 < args.length) i++;
    else return fail("option '" + name + "' requires an argument");
  }
}
// ...
const opt = shorts.get(ch);
if (!opt) return fail("invalid option -- '" + ch + "'");
if (opt.support === 'unsupported') {
  return fail(unsupportedMsg(opt, '-' + ch));
}

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment