DrKLO/Telegram · error

%s: only one input file

Error message

%s: only one input file

What it means

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.

Source

Thrown at TMessagesProj/jni/mozjpeg/rdjpgcom.c:482

  /* Parse switches, if any */
  for (argn = 1; argn < argc; argn++) {
    arg = argv[argn];
    if (arg[0] != '-')
      break;                    /* not switch, must be file name */
    arg++;                      /* advance over '-' */
    if (keymatch(arg, "verbose", 1)) {
      verbose++;
    } else if (keymatch(arg, "raw", 1)) {
      raw = 1;
    } else
      usage();
  }

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

View on GitHub (pinned to 45ab8f4308)

Solutions

  1. Pass only one file path per invocation and loop over files in a shell script: for f in *.jpg; do rdjpgcom "$f"; done.
  2. If you want to process all files, use find with -exec or xargs -L 1.

Example fix

# before
rdjpgcom *.jpg
# after
for f in *.jpg; do rdjpgcom "$f"; done
Defensive patterns

Strategy: validation

Validate before calling

# Ensure only one file argument is passed
if [ $# -gt 1 ]; then
  echo "Error: rdjpgcom accepts only one input file" >&2
  exit 1
fi
rdjpgcom "${1:-}"

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


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