{"record":{"id":"c3f4a4f5582b606c","repo":"DrKLO/Telegram","slug":"s-must-name-one-input-and-one-output-file-n","errorCode":null,"errorMessage":"%s: must name one input and one output file\\n","messagePattern":"(.+?): must name one input and one output file\\\\n","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"TMessagesProj/jni/mozjpeg/djpeg.c","lineNumber":571,"sourceCode":"   * the input file.\n   * (Exception: tracing level set here controls verbosity for COM markers\n   * found during jpeg_read_header...)\n   */\n\n  file_index = parse_switches(&cinfo, argc, argv, 0, FALSE);\n\n#ifdef TWO_FILE_COMMANDLINE\n  /* Must have either -outfile switch or explicit output file name */\n  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#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    }","sourceCodeStart":553,"sourceCodeEnd":589,"githubUrl":"https://github.com/DrKLO/Telegram/blob/45ab8f4308496e1f01026a97fcdb0d58a5274474/TMessagesProj/jni/mozjpeg/djpeg.c#L553-L589","documentation":"In djpeg's TWO_FILE_COMMANDLINE mode, when -outfile WAS given, it expects exactly one positional file (the input). If file_index != argc-1 there are extra positional files, this message prints, and usage() exits. Same message string as the no-outfile branch but a different trigger (extra positionals alongside -outfile).","triggerScenarios":"Passing -outfile <path> together with two or more positional file arguments, or zero positionals: djpeg -outfile out.ppm in1.jpg in2.jpg.","commonSituations":"Shell glob producing multiple inputs; copy-pasting a two-positional command then adding -outfile without removing the second positional; leftover args in a wrapper script.","solutions":["When using -outfile, pass exactly one positional input: djpeg -outfile out.ppm in.jpg.","Guard/quote globs to a single input, or loop invoking djpeg once per file.","Remove stray trailing positional arguments."],"exampleFix":"# before: -outfile plus two positionals\ndjpeg -outfile out.ppm in1.jpg in2.jpg\n# after\ndjpeg -outfile out.ppm in1.jpg","handlingStrategy":"validation","validationCode":"#!/bin/sh\nhas_outfile=0; pos=()\nfor a in \"$@\"; do case \"$a\" in -outfile) has_outfile=1;; -*) ;; *) pos+=(\"$a\");; esac; done\n[ \"$has_outfile\" -eq 1 ] && [ \"${#pos[@]}\" -ne 1 ] && { echo 'with -outfile, pass exactly one input file to djpeg' >&2; exit 1; }\ndjpeg \"$@\"","typeGuard":"// n/a: argv-count validation in the caller.","tryCatchPattern":"if ! djpeg \"$@\" 2>/tmp/e; then\n  grep -q 'must name one input and one output file' /tmp/e && { echo 'remove extra positional files when using -outfile'; exit 1; }\nfi","preventionTips":["Append exactly one input after -outfile.","Quote globs to prevent multi-file expansion.","Use 'set -u' in wrapper scripts to catch missing variables."],"tags":["mozjpeg","djpeg","cli-argument","commandline","extra-positional"],"backgroundTag":null,"analyzedSha":"45ab8f4308496e1f01026a97fcdb0d58a5274474","analyzedAt":"2026-08-14T05:19:30.815Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}