diff rvinterf/tmsh/main.c @ 71:27c41e4b21ae

fc-tmsh one-shot operation mode implemented
author Mychaela Falconia <falcon@freecalypso.org>
date Wed, 26 Oct 2016 23:51:47 +0000
parents 2c6dca514a20
children c1aadfcd185f
line wrap: on
line diff
--- a/rvinterf/tmsh/main.c	Wed Oct 26 23:33:21 2016 +0000
+++ b/rvinterf/tmsh/main.c	Wed Oct 26 23:51:47 2016 +0000
@@ -12,6 +12,7 @@
 char *socket_pathname = "/tmp/rvinterf_socket";
 char *rvinterf_ttyport;
 int ttyhacks, dflag;
+int oneshot_nowait;
 
 int sock;
 
@@ -25,7 +26,7 @@
 	int c, sopt = 0;
 	fd_set fds;
 
-	while ((c = getopt(argc, argv, "B:dl:p:s:w:")) != EOF)
+	while ((c = getopt(argc, argv, "B:dl:np:s:w:")) != EOF)
 		switch (c) {
 		case 'B':
 			rvinterf_Bopt = optarg;
@@ -36,6 +37,9 @@
 		case 'l':
 			rvinterf_lopt = optarg;
 			continue;
+		case 'n':
+			oneshot_nowait++;
+			continue;
 		case 'p':
 			rvinterf_ttyport = optarg;
 			continue;
@@ -48,8 +52,7 @@
 			continue;
 		case '?':
 		default:
-usage:			fprintf(stderr,
-				"usage: %s [options] [command]\n", argv[0]);
+			/* error msg already printed */
 			exit(ERROR_USAGE);
 		}
 	if (rvinterf_ttyport) {
@@ -70,6 +73,9 @@
 		connect_local_socket();
 	}
 
+	if (argv[optind])
+		return oneshot_command(argc - optind, argv + optind);
+
 	ttyhacks = isatty(0) && !dflag;
 	init();
 	tty_init();