{"record":{"id":"7202f34a86877f14","repo":"DrKLO/Telegram","slug":"s-only-one-input-file-7202f3","errorCode":null,"errorMessage":"%s: only one input file\n","messagePattern":"(.+?): only one input file\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"TMessagesProj/jni/mozjpeg/rdjpgcom.c","lineNumber":482,"sourceCode":"\n  /* Parse switches, if any */\n  for (argn = 1; argn < argc; argn++) {\n    arg = argv[argn];\n    if (arg[0] != '-')\n      break;                    /* not switch, must be file name */\n    arg++;                      /* advance over '-' */\n    if (keymatch(arg, \"verbose\", 1)) {\n      verbose++;\n    } else if (keymatch(arg, \"raw\", 1)) {\n      raw = 1;\n    } else\n      usage();\n  }\n\n  /* Open the input file. */\n  /* Unix style: expect zero or one file name */\n  if (argn < argc - 1) {\n    fprintf(stderr, \"%s: only one input file\\n\", progname);\n    usage();\n  }\n  if (argn < argc) {\n    if ((infile = fopen(argv[argn], READ_BINARY)) == NULL) {\n      fprintf(stderr, \"%s: can't open %s\\n\", progname, argv[argn]);\n      exit(EXIT_FAILURE);\n    }\n  } else {\n    /* default input file is stdin */\n#ifdef USE_SETMODE              /* need to hack file mode? */\n    setmode(fileno(stdin), O_BINARY);\n#endif\n#ifdef USE_FDOPEN               /* need to re-open in binary mode? */\n    if ((infile = fdopen(fileno(stdin), READ_BINARY)) == NULL) {\n      fprintf(stderr, \"%s: can't open stdin\\n\", progname);\n      exit(EXIT_FAILURE);\n    }\n#else","sourceCodeStart":464,"sourceCodeEnd":500,"githubUrl":"https://github.com/DrKLO/Telegram/blob/45ab8f4308496e1f01026a97fcdb0d58a5274474/TMessagesProj/jni/mozjpeg/rdjpgcom.c#L464-L500","documentation":"rdjpgcom accepts at most one input file path as a positional argument. The code checks if argn (the count of non-option arguments processed so far) is less than argc - 1, meaning more than one positional argument remains. If multiple file paths are passed, the program reports this error and calls usage() to print help. This enforces the Unix convention of one-file-or-stdin per invocation.","triggerScenarios":"Passing two or more file paths to rdjpgcom on the command line: 'rdjpgcom file1.jpg file2.jpg'. The argn counter is incremented after option parsing, and if argc - argn > 1, the error fires.","commonSituations":"Shell globbing that expands to multiple files ('rdjpgcom *.jpg'); scripts that loop incorrectly and pass multiple files in a single invocation; misunderstanding that rdjpgcom processes one file at a time.","solutions":["Pass only one file path per invocation and loop over files in a shell script: for f in *.jpg; do rdjpgcom \"$f\"; done.","If you want to process all files, use find with -exec or xargs -L 1."],"exampleFix":"# before\nrdjpgcom *.jpg\n# after\nfor f in *.jpg; do rdjpgcom \"$f\"; done","handlingStrategy":"validation","validationCode":"# Ensure only one file argument is passed\nif [ $# -gt 1 ]; then\n  echo \"Error: rdjpgcom accepts only one input file\" >&2\n  exit 1\nfi\nrdjpgcom \"${1:-}\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Loop over files in a for-loop when processing multiple JPEGs with rdjpgcom.","Use find with -exec or xargs -n 1 for batch processing.","Count positional arguments before invoking single-file CLI tools."],"tags":["cli","argument-error","mozjpeg"],"backgroundTag":null,"analyzedSha":"45ab8f4308496e1f01026a97fcdb0d58a5274474","analyzedAt":"2026-08-14T05:19:30.815Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}