|
|
|
@ -3,24 +3,25 @@
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
#include <pwd.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
|
|
#include "version.h"
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
whoami - prints the working user's username (unless --uid is specified)
|
|
|
|
|
yes - spams a message (by default `y`) to stdout.
|
|
|
|
|
Available arguments:
|
|
|
|
|
--help: show this help message
|
|
|
|
|
--version: show the version of the program (WIP)
|
|
|
|
|
--uid: print the users numeric UID, instead of username
|
|
|
|
|
--help: show this help message.
|
|
|
|
|
--version: show version of the program.
|
|
|
|
|
Usage:
|
|
|
|
|
yes [--help] [--version] [message]
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
int main(int argc, char** argv) {
|
|
|
|
|
char *spammy = malloc(sizeof(char) * 16);
|
|
|
|
|
if (argc == 1) {
|
|
|
|
|
do {
|
|
|
|
|
printf("y\n");
|
|
|
|
|
} while (1);
|
|
|
|
|
spammy = "y";
|
|
|
|
|
} else {
|
|
|
|
|
for (int i = 0; i < argc; i++) {
|
|
|
|
|
for (int i = 1; i < argc; i++) {
|
|
|
|
|
char* arg = argv[i];
|
|
|
|
|
/*printf(arg);
|
|
|
|
|
printf(" ");*/
|
|
|
|
@ -29,17 +30,25 @@ int main(int argc, char** argv) {
|
|
|
|
|
"Drake's Epic Coreutils (working title) "
|
|
|
|
|
DRAKECU_VERSION
|
|
|
|
|
"\n"
|
|
|
|
|
"yes - spams 'y'.\n"
|
|
|
|
|
"yes - spams a message (by default `y`) to stdout.\n"
|
|
|
|
|
"Available arguments:\n"
|
|
|
|
|
" --help: show this help message\n"
|
|
|
|
|
" --version: show the version of the program\n"
|
|
|
|
|
" --uid: print the users numeric UID, instead of username";
|
|
|
|
|
" --help: show this help message.\n"
|
|
|
|
|
" --version: show version of the program.\n"
|
|
|
|
|
"Usage:\n"
|
|
|
|
|
" yes [--help] [--version] [message]";
|
|
|
|
|
printf("%s\n", help);
|
|
|
|
|
return 0;
|
|
|
|
|
} else if (!strcmp(arg, "--version")) {
|
|
|
|
|
printf(DRAKECU_VERSION);
|
|
|
|
|
return 0;
|
|
|
|
|
} else {
|
|
|
|
|
spammy = realloc(spammy, strlen(arg) + strlen(spammy) + 1);
|
|
|
|
|
strcat(spammy, arg);
|
|
|
|
|
strcat(spammy, " ");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
do {
|
|
|
|
|
printf("%s\n", spammy);
|
|
|
|
|
} while (1);
|
|
|
|
|
}
|
|
|
|
|