Gracefully handle an *empty* argument array (argc < 1), which apparently is possible on Linux and maybe others.

This commit is contained in:
LoRd_MuldeR 2022-01-27 00:21:28 +01:00
parent 4caad0d279
commit 1c587be39b
Signed by: mulder
GPG Key ID: 2B5913365F57E03F

View File

@ -158,6 +158,12 @@ int MAIN(const int argc, CHR *const argv[])
/* Parse arguments */ /* Parse arguments */
/* ----------------------------------------------------- */ /* ----------------------------------------------------- */
if (argc < 1)
{
FPUTS(T("Error: Argument array is empty. The program was called incorrectly!\n\n"), stderr);
goto clean_up;
}
if (argc < 2) if (argc < 2)
{ {
FPRINTF(stderr, T("Error: Nothing to do. Please type '%") T(PRISTR) T(" --help' for details!\n\n"), get_file_name(argv[0U])); FPRINTF(stderr, T("Error: Nothing to do. Please type '%") T(PRISTR) T(" --help' for details!\n\n"), get_file_name(argv[0U]));