]> git.armaanb.net Git - bin.git/commitdiff
crontab-argh: add program
authorArmaan Bhojwani <me@armaanb.net>
Sun, 4 Apr 2021 23:53:49 +0000 (19:53 -0400)
committerArmaan Bhojwani <me@armaanb.net>
Sun, 4 Apr 2021 23:53:49 +0000 (19:53 -0400)
README.md
crontab-argh.c [new file with mode: 0755]

index 16d08335140dd0846c1db632d8b4908949567970..1faf80c747377006982e2d1a14b3ca4e62cd9922 100644 (file)
--- a/README.md
+++ b/README.md
@@ -1,4 +1,6 @@
-# scripts
-Some shell and Python scripts that make my life a bit easier. Many of them are inspired by other people's work and are marked accordingly in the script.
+# bin
+Some small programs that make my life a bit easier. Many of them are inspired by other people's work and are marked accordingly in the script.
 
-If not otherwise specified at the top of the file, all work in this repository is public domain. See the LICENSE file for more information.
+Some of these programs are interpreted scripts, whereas others are C programs that need to be compiled. The `autobuild` script is provided to automatically build all of the C programs, or alternatively, they can be run directly with `tcc -run`.
+
+If not otherwise specified at the top of the file, all work in this repository is dedicated to the public domain. See the LICENSE file for more information.
diff --git a/crontab-argh.c b/crontab-argh.c
new file mode 100755 (executable)
index 0000000..504073a
--- /dev/null
@@ -0,0 +1,29 @@
+// stops you from accidentally running crontab -r
+// alias this to crontab
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+int main(int argc, char *argv[]) {
+       char arg[255] = "crontab ";
+
+       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);
+       return 0;
+}