X-Git-Url: https://git.armaanb.net/?p=bin.git;a=blobdiff_plain;f=crontab-argh.c;h=5c40756df7e18fd24852d03b5f1e0107e6608b2f;hp=e50eb5322cecc822a3018ce50729144ee4077412;hb=HEAD;hpb=a3507e675b8b0435f26e0e54b242e6ea6c1a6a88 diff --git a/crontab-argh.c b/crontab-argh.c old mode 100755 new mode 100644 index e50eb53..5c40756 --- a/crontab-argh.c +++ b/crontab-argh.c @@ -1,28 +1,34 @@ -// stops you from accidentally running crontab -r -// alias this to crontab +/* Stops you from accidentally running crontab -r. alias this to crontab. + Alternatively, if you are on a GNU system, you can just alias "crontab + -r" to "crontab -ri", but this isn't POSIX. */ #include #include #include -int main(int argc, char *argv[]) { - char arg[255] = "crontab "; +int +main(int argc, char *argv[]) { + char arg[255] = "crontab "; - for (int i = 1; i < argc; i++) { - strcat(arg, strcat(argv[i], " ")); - } + for (int i = 1; i < argc; i++) { + strcat(arg, strcat(argv[i], " ")); + } - if (strstr(arg, "-r") != NULL) { - printf("%s", "Delete user's crontab? [yes/no]: "); - char inp[255]; - int ret; - while (1) { - ret = scanf("%s", inp); - if (ret == EOF) continue; - else if (strcmp(inp, "no") == 0) exit(0); - else if (strcmp(inp, "yes") == 0) break; - else printf("%s", "Please answer yes or no. [yes/no]: "); - } - } - system(arg); + if (strstr(arg, "-r") != NULL) { + printf("%s", "Delete user's crontab? [yes/no]: "); + char inp[255]; + int ret; + while (1) { + ret = scanf("%s", inp); + if (ret == EOF) + continue; + else if (strcmp(inp, "no") == 0) + exit(0); + else if (strcmp(inp, "yes") == 0) + break; + else + printf("%s", "Please answer yes or no. [yes/no]: "); + } + } + system(arg); }