fix: handle system() errors

This commit is contained in:
2025-07-18 21:31:03 -04:00
parent bd25ddaa52
commit 5ea2f16ba9

View File

@@ -104,10 +104,16 @@ create_project (format_t fmt)
return 1;
}
if (fmt.git)
system ("git init --quiet");
err = system ("git init --quiet");
if (err)
{
printfn ("failed on git initialize: %s", strerror (err));
return 1;
}
if (!fmt.name)
fmt.name = DEFAULT_USER_NAME;
create_file_with_content ("README",
create_file_with_content (
"README",
"%s ( concise description )\n\n"
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do "
"eiusmod tempor\n"
@@ -121,7 +127,8 @@ create_project (format_t fmt)
"proident, sunt in\n"
"culpa qui officia deserunt mollit anim id est laborum.",
fmt.project ? fmt.project : DEFAULT_PROJECT_NAME);
create_file_with_content ("configure",
create_file_with_content (
"configure",
"#!/bin/sh\n"
"\n"
"usage() {\n"
@@ -192,7 +199,8 @@ create_project (format_t fmt)
if (*p >= 'a' && *p <= 'z')
*p = *p - 'a' + 'A';
}
create_file_with_content ("Makefile",
create_file_with_content (
"Makefile",
"prefix = /usr/bin\n\n"
"%s_SRCS := $(wildcard *.c)\n"
"%s_OBJS := $(patsubst %%.c,c-out/obj/%%.o,$(%s_SRCS))\n\n"
@@ -228,7 +236,8 @@ create_project (format_t fmt)
mkfile_name, mkfile_name, mkfile_name);
free (mkfile_name);
if (fmt.clang_format)
create_file_with_content (".clang-format", "Language: Cpp\nBasedOnStyle: GNU\n");
create_file_with_content (".clang-format",
"Language: Cpp\nBasedOnStyle: GNU\n");
switch (fmt.licence)
{
case BSD3:
@@ -266,7 +275,8 @@ create_project (format_t fmt)
break;
}
create_and_enter_directory (fmt.project);
create_file_with_content ("main.c",
create_file_with_content (
"main.c",
"#include <stdio.h>\n\nint main(void) {\n printf(\"%s: Hello "
"%s!\\n\");\nreturn 0;\n}",
fmt.project ? fmt.project : DEFAULT_PROJECT_NAME,