This commit is contained in:
Your Name 2023-11-07 19:41:47 +03:00
parent c6b750f966
commit e1b6a32504
4 changed files with 15 additions and 19 deletions

View File

@ -35,9 +35,8 @@ void Compile(const char *src, const char *output_dir) {
char *path = MakePath(src, output_dir); char *path = MakePath(src, output_dir);
printf("[CC] Building %s -> %s\n", src, path); printf("[CC] Building %s -> %s\n", src, path);
if (fork()) { if (fork())
execlp(CC, CC, CFLAGS, src, "-o", path, NULL); execlp(CC, CC, CFLAGS, src, "-o", path, NULL);
}
free(path); free(path);
} }

View File

@ -19,12 +19,16 @@ int main(const int argc, const char **argv) {
else { else {
for (int i = 1; i < argc; i++) { for (int i = 1; i < argc; i++) {
if (argv[i][0] == '-') if (argv[i][0] == '-') {
if (argv[i][1]) if (argv[i][1])
break; continue;
else else
cat(STDIN_FILENO); cat(STDIN_FILENO);
continue;
}
int fd = open(argv[i], O_RDONLY); int fd = open(argv[i], O_RDONLY);
if (fd < 0) { if (fd < 0) {
fprintf(stderr, "cat: %s %s\n", argv[i], strerror(errno)); fprintf(stderr, "cat: %s %s\n", argv[i], strerror(errno));

View File

@ -8,8 +8,9 @@ int main(const int argc, const char **argv) {
putchar(' '); 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'); putchar('\n');
return 0; return 0;
} }

View File

@ -5,20 +5,13 @@
#include <unistd.h> #include <unistd.h>
int main(const int argc, const char **argv) { int main(const int argc, const char **argv) {
int i; if (argv[argc - 1][0] == '-') {
for (i = 1; i < argc; i++) { printf("hostname [hostname Set new hostname]\n");
if (argv[i][0] != '-') return 0;
break;
else if (!strcmp(argv[i], "--help")) {
printf("hostname [hostname Set new hostname]\n");
return 0;
}
} }
/* Set hostname */ /* Set hostname */
if (argc - i == 1) { if (argc == 2) {
if (sethostname(argv[argc - 1], strlen(argv[argc - 1])) < 0) { if (sethostname(argv[argc - 1], strlen(argv[argc - 1])) < 0) {
fprintf(stderr, "hostname: %s\n", strerror(errno)); fprintf(stderr, "hostname: %s\n", strerror(errno));
return 1; return 1;
@ -34,7 +27,6 @@ int main(const int argc, const char **argv) {
return 1; return 1;
} }
puts(hostname); puts(hostname);
return 0; return 0;
} }