help formatting, remove segv involving no filename after nth option

This commit is contained in:
Chad C. Starz 2024-06-08 18:31:53 +00:00
parent 481638424b
commit 9656fa557f
No known key found for this signature in database
GPG Key ID: CEEBC9208C287297

12
bake.c
View File

@ -37,8 +37,8 @@
#define DESC \
"Options [Must always be put first, may be merged together]\n" \
"\t" DIM "-v --version" RESET ", " DIM "-h --help" RESET ", " \
BOLD "-n --dry-run" RESET ", " BOLD "-x --expunge\n" RESET ", " \
BOLD "-c --color" RESET \
BOLD "-n --dry-run" RESET ", " BOLD "-x --expunge" RESET ", " \
BOLD "-c --color\n" RESET \
"Expansions\n" \
"\t" YELLOW "@FILENAME" RESET " returns target-file (abc.x.txt)\n" \
"\t" YELLOW "@SHORT " RESET " returns target-file without suffix (^-> abc.x)\n" \
@ -570,6 +570,14 @@ main(int argc, char ** argv) {
next:;
}
if (!argc)
{
color_fprintf(stderr, BOLD RED "%s" RESET
": No filename provided\n",
argv0);
return BAKE_ERROR;
}
filename = argv[0];
++argv, --argc;