diff --git a/builder/builder.c b/builder/builder.c index f1a2080..035e82d 100644 --- a/builder/builder.c +++ b/builder/builder.c @@ -35,10 +35,9 @@ void Compile(const char *src, const char *output_dir) { char *path = MakePath(src, output_dir); printf("[CC] Building %s -> %s\n", src, path); - if (fork()) { + if (fork()) execlp(CC, CC, CFLAGS, src, "-o", path, NULL); - } - + free(path); } diff --git a/coreutils/cat.c b/coreutils/cat.c index d3e3c97..ccd1a0e 100644 --- a/coreutils/cat.c +++ b/coreutils/cat.c @@ -19,12 +19,16 @@ int main(const int argc, const char **argv) { else { for (int i = 1; i < argc; i++) { - if (argv[i][0] == '-') + if (argv[i][0] == '-') { if (argv[i][1]) - break; + continue; + else cat(STDIN_FILENO); + continue; + } + int fd = open(argv[i], O_RDONLY); if (fd < 0) { fprintf(stderr, "cat: %s %s\n", argv[i], strerror(errno)); diff --git a/coreutils/echo.c b/coreutils/echo.c index 9146b2b..32807ed 100644 --- a/coreutils/echo.c +++ b/coreutils/echo.c @@ -8,8 +8,9 @@ int main(const int argc, const char **argv) { putchar(' '); } } - // https://pubs.opengroup.org/onlinepubs/009604599/utilities/echo.html - // This version does not support -n option and escape-sequences + + /* https://pubs.opengroup.org/onlinepubs/009604599/utilities/echo.html */ + /* This version does not support -n option and escape-sequences */ putchar('\n'); return 0; } diff --git a/networking/hostname.c b/networking/hostname.c index af4087c..9c60f40 100644 --- a/networking/hostname.c +++ b/networking/hostname.c @@ -5,20 +5,13 @@ #include int main(const int argc, const char **argv) { - int i; - for (i = 1; i < argc; i++) { - if (argv[i][0] != '-') - break; - - else if (!strcmp(argv[i], "--help")) { - printf("hostname [hostname Set new hostname]\n"); - return 0; - } + if (argv[argc - 1][0] == '-') { + printf("hostname [hostname Set new hostname]\n"); + return 0; } - /* Set hostname */ - if (argc - i == 1) { + if (argc == 2) { if (sethostname(argv[argc - 1], strlen(argv[argc - 1])) < 0) { fprintf(stderr, "hostname: %s\n", strerror(errno)); return 1; @@ -34,7 +27,6 @@ int main(const int argc, const char **argv) { return 1; } - puts(hostname); return 0; }