DrKLO/Telegram · error

%s: only one input file\n

Error message

%s: only one input file\n

What it means

In the Unix-style (non-TWO_FILE_COMMANDLINE) build, wrjpgcom accepts zero or one positional input file. If more than one positional arg remains (argn < argc - 1), it prints `%s: only one input file`, calls usage(), and exits. This guards against multiple input files being passed.

Source

Thrown at TMessagesProj/jni/mozjpeg/wrjpgcom.c:527

    infile = stdin;
#endif
  }

  /* Open the output file. */
#ifdef TWO_FILE_COMMANDLINE
  /* Must have explicit output file name */
  if (argn != argc - 2) {
    fprintf(stderr, "%s: must name one input and one output file\n", progname);
    usage();
  }
  if ((outfile = fopen(argv[argn + 1], WRITE_BINARY)) == NULL) {
    fprintf(stderr, "%s: can't open %s\n", progname, argv[argn + 1]);
    exit(EXIT_FAILURE);
  }
#else
  /* Unix style: expect zero or one file name */
  if (argn < argc - 1) {
    fprintf(stderr, "%s: only one input file\n", progname);
    usage();
  }
  /* default output file is stdout */
#ifdef USE_SETMODE              /* need to hack file mode? */
  setmode(fileno(stdout), O_BINARY);
#endif
#ifdef USE_FDOPEN               /* need to re-open in binary mode? */
  if ((outfile = fdopen(fileno(stdout), WRITE_BINARY)) == NULL) {
    fprintf(stderr, "%s: can't open stdout\n", progname);
    exit(EXIT_FAILURE);
  }
#else
  outfile = stdout;
#endif
#endif /* TWO_FILE_COMMANDLINE */

  /* Collect comment text from comment_file or stdin, if necessary */
  if (comment_arg == NULL) {

View on GitHub (pinned to 45ab8f4308)

Solutions

  1. Pass at most one positional input file per invocation.
  2. Loop over inputs in the shell rather than listing them on one command line.
  3. Quote/validate the argument list length before invoking wrjpgcom.

Example fix

// before
wrjpgcom -comment hi *.jpg
// after
for f in *.jpg; do wrjpgcom -comment hi "$f" > "$f.cmt"; done
Defensive patterns

Strategy: validation

Validate before calling

/* Unix-style build: at most one positional input */
if (argc_after_switches > 1) { /* loop per-file instead of batching */ }

Prevention

When it happens

Trigger: Running a Unix-style build with two or more positional file arguments, e.g. `wrjpgcom in1.jpg in2.jpg`.

Common situations: Glob expanding to multiple JPEGs, or scripting a loop that accidentally passes several files in one invocation.

Related errors


AI-assisted analysis of DrKLO/Telegram@45ab8f4308 (2026-08-14). Data as JSON: /api/errors/4fb43586ed6bd5c6. Report an issue: GitHub.