// orphan.c, version 1.0.1 // OMKOV coreutils orphan // Copyright (C) 2020, Jakob Wakeling // MIT Licence #include "util/error.h" #include "util/optget.h" #include #include #include #include #define VERSION "1.0.1" static struct lop lops[] = { { "help", ARG_NUL, 256 }, { "version", ARG_NUL, 257 }, { NULL, 0, 0 } }; static void hlp(void); static void ver(void); int main(int ac, char *av[]) { A0 = av[0]; struct opt opt = OPTGET_INIT; opt.str = ""; opt.lops = lops; for (int o; (o = optget(&opt, av, 0)) != -1;) switch (o) { case 256: { hlp(); return 0; } case 257: { ver(); return 0; } default: { return 1; } } if (opt.ind == ac) { error(1, "missing operand"); } switch (fork()) { case -1: { error(1, "%s", serr()); } case 0: { execvp(av[opt.ind], &av[opt.ind]); warn("%s: %s", av[opt.ind], serr()); } default: { return 0; } } } static void hlp(void) { puts("orphan - invoke a command as an orphan\n"); puts("usage: orphan command [argument...]\n"); puts("options:"); puts(" --help Display help information"); puts(" --version Display version information"); } static void ver(void) { puts("OMKOV cryptutils orphan, version " VERSION); puts("Copyright (C) 2020, Jakob Wakeling"); puts("MIT Licence (https://opensource.org/licenses/MIT)"); }