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,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);
}

View File

@ -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));

View File

@ -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;
}

View File

@ -5,20 +5,13 @@
#include <unistd.h>
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;
}