]> git.xolatile.top Git - emil-bake.git/commitdiff
help formatting, remove segv involving no filename after nth option
authorEmil Williams <emilemilemil@cock.li>
Sat, 8 Jun 2024 18:31:53 +0000 (18:31 +0000)
committerEmil Williams <emilemilemil@cock.li>
Sat, 8 Jun 2024 18:31:53 +0000 (18:31 +0000)
bake.c

diff --git a/bake.c b/bake.c
index d5a1dd7d2a93fd44976b24a493201f55c7bd002f..dfc7a7bb955fe4b01e5957ea345e13e5abec4145 100644 (file)
--- a/bake.c
+++ b/bake.c
@@ -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;