{"record":{"id":"75a5a414a4de30bf","repo":"DrKLO/Telegram","slug":"s-must-name-one-input-and-one-output-file","errorCode":null,"errorMessage":"%s: must name one input and one output file\n","messagePattern":"(.+?): must name one input and one output file\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"TMessagesProj/jni/mozjpeg/cjpeg.c","lineNumber":718,"sourceCode":"   */\n\n  cinfo.in_color_space = JCS_RGB; /* arbitrary guess */\n  jpeg_set_defaults(&cinfo);\n\n  /* Scan command line to find file names.\n   * It is convenient to use just one switch-parsing routine, but the switch\n   * values read here are ignored; we will rescan the switches after opening\n   * the input file.\n   */\n\n  file_index = parse_switches(&cinfo, argc, argv, 0, FALSE);\n\n#ifdef TWO_FILE_COMMANDLINE\n  if (!memdst) {\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  }\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  }","sourceCodeStart":700,"sourceCodeEnd":736,"githubUrl":"https://github.com/DrKLO/Telegram/blob/45ab8f4308496e1f01026a97fcdb0d58a5274474/TMessagesProj/jni/mozjpeg/cjpeg.c#L700-L736","documentation":"In TWO_FILE_COMMANDLINE mode, when no -outfile switch was given, cjpeg expects exactly two positional file arguments (input and output). If file_index (the count of non-switch positionals after parsing) is not argc-2, the count is wrong and this message prints, then usage() exits. This branch covers the missing-output-file case.","triggerScenarios":"Calling cjpeg with no -outfile and not exactly two positional arguments: zero, one, or three+ positional file names (e.g. only an input file, or input plus multiple outputs).","commonSituations":"Expecting cjpeg to write to stdout when TWO_FILE_COMMANDLINE is defined (it does not in this mode); forgetting the output argument; shell glob expanding to many files; piping assumptions.","solutions":["Provide exactly one input and one output file positionally when not using -outfile, e.g. cjpeg in.ppm out.jpg.","Alternatively use -outfile <path> and pass a single input positional.","If you need stdout output, use a build without TWO_FILE_COMMANDLINE or redirect the single output to /dev/stdout."],"exampleFix":"# before: only input given, no output\ncjpeg in.ppm\n# after\ncjpeg in.ppm out.jpg\n# or\ncjpeg -outfile out.jpg in.ppm","handlingStrategy":"validation","validationCode":"#!/bin/sh\n# Ensure exactly two positionals when no -outfile is present (TWO_FILE_COMMANDLINE build)\nhas_outfile=0; pos=()\nfor a in \"$@\"; do case \"$a\" in -outfile) has_outfile=1;; -*) ;; *) pos+=(\"$a\");; esac; done\n[ \"$has_outfile\" -eq 0 ] && [ \"${#pos[@]}\" -ne 2 ] && { echo 'need exactly one input and one output file' >&2; exit 1; }\ncjpeg \"$@\"","typeGuard":"// n/a: argv-count validation in the caller.","tryCatchPattern":"if ! cjpeg \"$@\" 2>/tmp/e; then\n  grep -q 'must name one input and one output file' /tmp/e && { echo 'supply input + output (or use -outfile)'; exit 1; }\nfi","preventionTips":["In wrapper scripts, separate options from positionals explicitly and assert the positional count before exec.","Default to -outfile for explicit output to avoid ambiguity.","Document which build flavor (TWO_FILE_COMMANDLINE) is deployed."],"tags":["mozjpeg","cjpeg","cli-argument","commandline","missing-output"],"backgroundTag":null,"analyzedSha":"45ab8f4308496e1f01026a97fcdb0d58a5274474","analyzedAt":"2026-08-14T05:19:30.815Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}