phacility/phabricator · warning · PhutilArgumentUsageException

Specify exactly one file to print, like

Error message

Specify exactly one file to print, like "%s".

What it means

The `./bin/files cat` workflow takes a single file name as its wildcard argument; passing more than one name is rejected as a usage error before anything is read. The message suggests the F123 monogram form. Each invocation prints exactly one file's bytes.

Solutions

  1. Print one file per invocation, or loop in the shell: `for f in F123 F456; do ./bin/files cat "$f"; done`
  2. Quote arguments so a single name is passed unexpanded

Example fix

# before
./bin/files cat F123 F456

# after
for f in F123 F456; do ./bin/files cat "$f"; done
Defensive patterns

Strategy: validation

Validate before calling

# In shell scripts, enforce the single-argument contract before invoking:
[ $# -eq 1 ] || { echo 'usage: dump.sh <file-monogram>' >&2; exit 2; }
./bin/files cat "$1"

Prevention

When it happens

Trigger: Running `./bin/files cat F123 F456`; passing a glob the shell expanded into multiple names.

Common situations: Scripting bulk extraction and assuming cat is variadic like `cat(1)`; unquoted shell globs expanding unexpectedly.

Related errors


AI-assisted analysis of phacility/phabricator@5720a38cfe (2026-08-21). Data as JSON: /api/errors/d14e2002340b6290. Report an issue: GitHub.

Appendix: source

Thrown at src/applications/files/management/PhabricatorFilesManagementCatWorkflow.php:41

            'name' => 'salvage',
            'help' => pht(
              'DANGEROUS. Attempt to salvage file content even if the '.
              'integrity check fails. If an adversary has tampered with '.
              'the file, the content may be unsafe.'),
          ),
          array(
            'name'      => 'names',
            'wildcard'  => true,
          ),
        ));
  }

  public function execute(PhutilArgumentParser $args) {
    $console = PhutilConsole::getConsole();

    $names = $args->getArg('names');
    if (count($names) > 1) {
      throw new PhutilArgumentUsageException(
        pht('Specify exactly one file to print, like "%s".', 'F123'));
    } else if (!$names) {
      throw new PhutilArgumentUsageException(
        pht('Specify a file to print, like "%s".', 'F123'));
    }

    $file = head($this->loadFilesWithNames($names));

    $begin = $args->getArg('begin');
    $end = $args->getArg('end');

    $file->makeEphemeral();

    // If we're running in "salvage" mode, wipe out any integrity hash which
    // may be present. This makes us read file data without performing an
    // integrity check.
    $salvage = $args->getArg('salvage');
    if ($salvage) {

View on GitHub (pinned to 5720a38cfe)