{"record":{"id":"f694ce85865350e0","repo":"DrKLO/Telegram","slug":"s-only-one-input-file","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/cjpeg.c","lineNumber":734,"sourceCode":"    if (outfilename == NULL) {\n      if (file_index != argc - 2) {\n        fprintf(stderr, \"%s: must name one input and one output file\\n\",\n                progname);\n        usage();\n      }\n      outfilename = argv[file_index + 1];\n    } else {\n      if (file_index != argc - 1) {\n        fprintf(stderr, \"%s: must name one input and one output file\\n\",\n                progname);\n        usage();\n      }\n    }\n  }\n#else\n  /* Unix style: expect zero or one file name */\n  if (file_index < argc - 1) {\n    fprintf(stderr, \"%s: only one input file\\n\", progname);\n    usage();\n  }\n#endif /* TWO_FILE_COMMANDLINE */\n\n  /* Open the input file. */\n  if (file_index < argc) {\n    if ((input_file = fopen(argv[file_index], READ_BINARY)) == NULL) {\n      fprintf(stderr, \"%s: can't open %s\\n\", progname, argv[file_index]);\n      exit(EXIT_FAILURE);\n    }\n  } else {\n    /* default input file is stdin */\n    input_file = read_stdin();\n  }\n\n  /* Open the output file. */\n  if (outfilename != NULL) {\n    if ((output_file = fopen(outfilename, WRITE_BINARY)) == NULL) {","sourceCodeStart":716,"sourceCodeEnd":752,"githubUrl":"https://github.com/DrKLO/Telegram/blob/45ab8f4308496e1f01026a97fcdb0d58a5274474/TMessagesProj/jni/mozjpeg/cjpeg.c#L716-L752","documentation":"When TWO_FILE_COMMANDLINE is NOT defined (Unix single-file style), cjpeg accepts at most one positional input (output goes to stdout). If file_index < argc-1 there is more than one positional file and this message prints, then usage() exits.","triggerScenarios":"Running a non-TWO_FILE_COMMANDLINE build of cjpeg with two or more positional file arguments.","commonSituations":"Switching from a TWO_FILE_COMMANDLINE build (where two positionals are normal) to a Unix-style build and keeping the old invocation; shell glob producing multiple files; wrapper scripts that always append an output path.","solutions":["Pass at most one positional input file and redirect stdout for output, e.g. cjpeg in.ppm > out.jpg.","If you need two-positional semantics, rebuild with TWO_FILE_COMMANDLINE defined or use -outfile.","Collapse globs/loops to a single input per invocation."],"exampleFix":"# before: two positionals on a Unix-style build\ncjpeg in.ppm out.jpg\n# after\ncjpeg in.ppm > out.jpg","handlingStrategy":"validation","validationCode":"#!/bin/sh\n# Unix-style build: at most one positional input\npos=()\nfor a in \"$@\"; do case \"$a\" in -*) ;; *) pos+=(\"$a\");; esac; done\n[ \"${#pos[@]}\" -gt 1 ] && { echo 'this cjpeg build accepts at most one input file; redirect stdout for output' >&2; exit 1; }\ncjpeg \"$@\"","typeGuard":"// n/a: argv-count validation in the caller.","tryCatchPattern":"if ! cjpeg \"$@\" 2>/tmp/e; then\n  grep -q 'only one input file' /tmp/e && { echo 'this build is Unix-style; use one input + stdout redirect'; exit 1; }\nfi","preventionTips":["Know which commandline style your binary was built with and document it.","Prefer redirecting stdout (cjpeg in > out) for portability across build styles.","In scripts, loop over multiple inputs rather than passing them all at once."],"tags":["mozjpeg","cjpeg","cli-argument","commandline","too-many-inputs"],"backgroundTag":null,"analyzedSha":"45ab8f4308496e1f01026a97fcdb0d58a5274474","analyzedAt":"2026-08-14T05:19:30.815Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}