X-Git-Url: https://tinc-vpn.org/git/browse?p=tinc;a=blobdiff_plain;f=src%2Ftincctl.c;h=c0c8a25662bb17ce1b08e97ed7b4f6cb7d98c8a0;hp=799da0aa192105cee261392d58c53bf502f8df96;hb=cc9203ee75c49360dd29710ac12bb67fe503f97b;hpb=afb175873e6aa10d2d4dca3572edf054968c538d diff --git a/src/tincctl.c b/src/tincctl.c index 799da0aa..c0c8a256 100644 --- a/src/tincctl.c +++ b/src/tincctl.c @@ -75,6 +75,7 @@ char *scriptextension = ""; static char *prompt; static struct option const long_options[] = { + {"batch", no_argument, NULL, 'b'}, {"config", required_argument, NULL, 'c'}, {"net", required_argument, NULL, 'n'}, {"help", no_argument, NULL, 1}, @@ -100,6 +101,7 @@ static void usage(bool status) { } else { printf("Usage: %s [options] command\n\n", program_name); printf("Valid options are:\n" + " -b, --batch Don't ask for anything (non-interactive mode).\n" " -c, --config=DIR Read configuration options from DIR.\n" " -n, --net=NETNAME Connect to net NETNAME.\n" " --pidfile=FILENAME Read control cookie from FILENAME.\n" @@ -158,6 +160,10 @@ static bool parse_options(int argc, char **argv) { case 0: /* long option */ break; + case 'b': + tty = false; + break; + case 'c': /* config file */ confbase = xstrdup(optarg); confbasegiven = true; @@ -2439,6 +2445,7 @@ int main(int argc, char *argv[]) { program_name = argv[0]; orig_argv = argv; orig_argc = argc; + tty = isatty(0) && isatty(1); if(!parse_options(argc, argv)) return 1; @@ -2469,8 +2476,6 @@ int main(int argc, char *argv[]) { srand(time(NULL)); crypto_init(); - tty = isatty(0) && isatty(1); - if(optind >= argc) return cmd_shell(argc, argv);