{"record":{"id":"d14e2002340b6290","repo":"phacility/phabricator","slug":"specify-exactly-one-file-to-print-like-s","errorCode":null,"errorMessage":"Specify exactly one file to print, like \"%s\".","messagePattern":"Specify exactly one file to print, like \"(.+?)\"\\.","errorType":"console","errorClass":"PhutilArgumentUsageException","httpStatus":null,"severity":"warning","filePath":"src/applications/files/management/PhabricatorFilesManagementCatWorkflow.php","lineNumber":41,"sourceCode":"            'name' => 'salvage',\n            'help' => pht(\n              'DANGEROUS. Attempt to salvage file content even if the '.\n              'integrity check fails. If an adversary has tampered with '.\n              'the file, the content may be unsafe.'),\n          ),\n          array(\n            'name'      => 'names',\n            'wildcard'  => true,\n          ),\n        ));\n  }\n\n  public function execute(PhutilArgumentParser $args) {\n    $console = PhutilConsole::getConsole();\n\n    $names = $args->getArg('names');\n    if (count($names) > 1) {\n      throw new PhutilArgumentUsageException(\n        pht('Specify exactly one file to print, like \"%s\".', 'F123'));\n    } else if (!$names) {\n      throw new PhutilArgumentUsageException(\n        pht('Specify a file to print, like \"%s\".', 'F123'));\n    }\n\n    $file = head($this->loadFilesWithNames($names));\n\n    $begin = $args->getArg('begin');\n    $end = $args->getArg('end');\n\n    $file->makeEphemeral();\n\n    // If we're running in \"salvage\" mode, wipe out any integrity hash which\n    // may be present. This makes us read file data without performing an\n    // integrity check.\n    $salvage = $args->getArg('salvage');\n    if ($salvage) {","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/files/management/PhabricatorFilesManagementCatWorkflow.php#L23-L59","documentation":"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.","triggerScenarios":"Running `./bin/files cat F123 F456`; passing a glob the shell expanded into multiple names.","commonSituations":"Scripting bulk extraction and assuming cat is variadic like `cat(1)`; unquoted shell globs expanding unexpectedly.","solutions":["Print one file per invocation, or loop in the shell: `for f in F123 F456; do ./bin/files cat \"$f\"; done`","Quote arguments so a single name is passed unexpanded"],"exampleFix":"# before\n./bin/files cat F123 F456\n\n# after\nfor f in F123 F456; do ./bin/files cat \"$f\"; done","handlingStrategy":"validation","validationCode":"# In shell scripts, enforce the single-argument contract before invoking:\n[ $# -eq 1 ] || { echo 'usage: dump.sh <file-monogram>' >&2; exit 2; }\n./bin/files cat \"$1\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Quote file arguments so shell globs do not expand into multiple names","Loop over names in the shell instead of passing several to one invocation"],"tags":["cli","usage","files","phabricator"],"backgroundTag":"too-many-arguments","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}